http://www.mathworks.de/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2014-10-23T14:26:07Ztag:www.mathworks.de,2005:Question/1598302014-10-23T14:22:27Z2014-10-23T14:26:07Zfminsearch for complex input for curve fitting<p>Dear all,
I would like to fit experimental data with custom equations. I aim for the best fit of the theoretical curve to the experimental data by minimizing the residuals and use fminsearch to find minimal error.</p><p>The attached code works well for the real inputs</p><p>[R, fval] = fminsearch(err, 2.11)% finds the minimum of err But it fails for the</p><p>[R, fval] = fminsearch(err, 2.0-0.064i)</p><p>Help for fminsearch suggests to input split into real, imaginary parts and work to obtain the best fit. I have a little idea of doing this.</p><p>Could somebody help me with this problem? Thanks all.</p>VISWANATH/matlabcentral/answers/contributors/867021-viswanathtag:www.mathworks.de,2005:Question/1598022014-10-23T11:35:46Z2014-10-23T14:22:06ZSection a 2d matrix and put the sections into a 3d matrix<p>Hi,</p><p>I have a question, if I have a matrix, lets say a 3x12 matrix:</p><pre class="language-matlab">a=
1 1 1
1 1 1
1 1 1
1 1 1
2 2 2
2 2 2
2 2 2
2 2 2
3 3 3
3 3 3
3 3 3
3 3 3
</pre><p>is there a method other than for looping to section this matrix and place the elements in a 3d matrix such, that it has a structure of (without changing the position of the 1, 2, 3 elements):</p><pre class="language-matlab">b(:,:,1) =
</pre><pre> 1 1 1
1 1 1
1 1 1
1 1 1</pre><pre class="language-matlab">b(:,:,2) =
</pre><pre> 2 2 2
2 2 2
2 2 2
2 2 2</pre><pre class="language-matlab">b(:,:,3) =
</pre><pre> 3 3 3
3 3 3
3 3 3
3 3 3</pre><p>Is there a method doing this without using for looping?</p>lee/matlabcentral/answers/contributors/5210112-leetag:www.mathworks.de,2005:Question/1597972014-10-23T10:46:41Z2014-10-23T14:21:49ZError using ode45 in matlab<p>Hi guys</p><p>I have a block and spring system with no damping. I'm given the equation x'' = -k*(x1 - L1)/m + k*(x2-x1-w1-L2)/m. Where k = spring stiffness; x1 = initial position of block; L1 = length of spring; x2 = initial position of the end of block; w1 = width of block; L2 = length of second block.</p><p>I have converted the second order ode into 2 first order odes.</p><p>u1' = x1' = u2</p><p>u2' = -k*(u1 - L1)/m + k*(u3-u1-w1-L2)/m</p><p>This is my function</p><p>function ydot = jipo1(t,y)</p><p>m = 2; % mass of the block</p><p>k = 5; % Spring stiffness</p><p>L1 = 2; % length of unstretched spring</p><p>k2 = 5; % Spring stiffness</p><p>L2 = 2; % length of unstretched spring</p><p>w1 = 5; % length of block</p><p>yd1 = y(2);</p><p>yd2 = -k*(y(1)-L1)/m + k2*(y(3)-y(1))/m</p><p>ydot = [yd1;yd2];</p><p>end</p><p>This is my ode45 script</p><p>clc</p><p>m1 = 2; % mass of the block</p><p>k = 5; % Spring stiffness</p><p>k2 = 5; % Spring stiffness</p><p>wn1 = sqrt(k/m1); % Natural frequency</p><p>t_final = 20; % Calculation time</p><p>L1 = 2; % length of unstretched spring</p><p>L2 = 2; % length of unstretched spring</p><p>w1 = 5; % length of blockk</p><p>x1_0 = 2; % Initial displacement</p><p>x_dot_0 = 0; % initial velocity</p><p>X_0 = [x1_0,x_dot_0]; % form a vector (array) of initial conditions</p><p>[t,y] = ode45(@jipo1,[0,t_final],X_0);</p><p>When I run it Matlab gives me this error.</p><p>Error in ode45 (line 114)</p><p>[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0,
odeArgs, odeFcn, ...</p><p>Error in jipo (line 18)</p><p>[t,y] = ode45(@jipo1,[0,t_final],X_0);</p><p>I would really appreciate any help that will help me understand what I'm doing wrong.</p>tyler brecht/matlabcentral/answers/contributors/5574479-tyler-brechttag:www.mathworks.de,2005:Question/1598292014-10-23T14:20:31Z2014-10-23T14:20:31ZHow to Compare different signals<p>Hello,</p><p>I have some noise measurements and 4 different models that can generate a similar noises using estimated parameters from the real measurements. To compare the estimated noises I calculated the PDF, the CCDF and the PSD.</p><p>To compare the results I used the Kull-Back Leibler divergence of the PDF, the MSE of the CCDF and the RMSE and the corr2 matlab function for the PSD.</p><pre> I am not sure if I did the right thing. </pre><p>Can you please tell me if what I did is correct and do you know any other way or function to make such comparison?</p><p>Thanks.</p>Ismail/matlabcentral/answers/contributors/5242087-ismailtag:www.mathworks.de,2005:Question/1596462014-10-22T11:34:55Z2014-10-23T14:18:23ZLinux UDP Send block fails to send to broadcast address<p>I have a Simulink model that generates target code to run under Embedded Linux (3.3.0) on a target OMAP-L138 LCDK board. The model periodically uses a Linux UDP Send block to transmit a small packet of data to a host PC. The block parameters are: port 7000, address '10.255.255.255'. When I generate the code a file called linuxUDP.c is created. If I build the code and download to the target and run it I never see the UDP message coming from the board.</p><p>I found that I have to manually edit the linuxUDP.c file to add a 'broadcast' option to the socket, i.e;:</p><p>int BroadcastEnable = 1;</p><p>setsockopt(((TgtSockStructT *) device)->sockfd, SOL_SOCKET,
SO_BROADCAST, &BroadcastEnable , 4);</p><p>Then when I build the modified code and run it everything works fine and the UDP message is transmitted from the target.</p><p>Is this a bug with the generated code from the model or am I doing something wrong with the block that is stopping the broadcast message from being sent? I tried using address '255.255.255.255' but I still had to make the same mods to the linuxUDP.c to get the message to be sent.</p>Mike Bardill/matlabcentral/answers/contributors/841081-mike-bardilltag:www.mathworks.de,2005:Question/1581602014-10-10T14:16:19Z2014-10-23T14:17:32ZLatex Interpreter MATLAB title underscores<p>Hi there,</p><p>I was using this title command as the title of the plot:
title(['File:' filename 'Stim electr: 'num2str(StimElectr(n))])</p><p>The filename contains underscores that are interpreted as subscripts in my MATLAB 2013b. Turning off the LaTEX interpreter locally seems to work only when I do not include the strings 'File:' and 'Stim electr' in my title command.</p><p>In other words, this works fine: title(filename,'interpreter','none') and underscores are kept as they are, but this doesn't: title(['File:' filename, 'interpreter', 'none']).</p><p>How can I keep the underscores for my initial title command?? (back slash etc I cannot use coz I cannot change the filename manually each time)</p><p>Thanx a lot!!
Stelina</p>Stelina/matlabcentral/answers/contributors/3722431-stelinatag:www.mathworks.de,2005:Question/1598282014-10-23T14:16:07Z2014-10-23T14:16:07Zunexpected xlim behavior - where is the documentation/code for how xlim gets updated<p>Is the way that the xlim property of an axes changes documented? I have some code that waits a bit - via a timer - after a series of axes manipulations are done, before finally updating a plot (see pseudocode below). I found however that if I wait to replot after zooming out, the algorithm decides that my data doesn't encompass the wide range that I zoomed out to, and then shrinks the xlim values accordingly.</p><p>In other words, let's say the original data spans from 0 to 100. Then I zoom from 30 to 60. When plotting for xlim = [30 60], I only plot data from 30 to 60. Then I zoom back out to 0 to 100 via a zoom reset (mouse double click). A timer is started in the xlim change callback. If the change is stable, then I'll replot things from 0 to 100. However, if another xlim change occurs, perhaps from quick zooming or panning, then I hold off on rerendering until all the input stops, at which point I use the latest xlim value.</p><p>This is the rough pseudocode:</p><p>xlim_changed_callback:
%Responding to xlim postset listener for axes</p><pre> delete(old_timer)
start(new_timer)</pre><p>timer_callback:</p><pre> updatePlot</pre><p>However, by waiting to plot, the xlim algorithm appears to check the resulting data span (somehow) and determines that the data doesn't encompass the region of 0 to 100, and changes its value again, so that it fits the data (which has yet to be updated). Thus the latest xlim value that I have to work with is close to being back to 30 to 60, even though at one point the value was changed to the proper value of 0 to 100.</p><p>Issue 2: As a workaround I quickly plot a temporary line on every callback that spans the xlim range, so that the algorithm doesn't decide to change the xlim value. When the timer actually executes, I then replot the lines with valid data.</p><p>However, this causes a slight adjustment of the xlim values. In the example above, my xlim value of [0 100] will change to [0.000001 100]. What is causing this? Can I prevent this from happening? My current workaround is to check for this "small" change and to ignore setting the new timer if this occurs.</p><p>Any incite into this whole process or suggestions would be much appreciated.</p><p>Thanks,
Jim</p>Jim Hokanson/matlabcentral/answers/contributors/937359-jim-hokansontag:www.mathworks.de,2005:Question/1598122014-10-23T12:46:36Z2014-10-23T14:15:02ZSymbolic Math Toolbox - Derive a function with respect to another function<p>Hello,</p><p>i want to verify a calculation I did already on paper. There the following problem occurs:</p><pre class="language-matlab">>> clear all
>> syms t x(t)
>> f=3*x
>> diff(f,x)
Error using sym/diff (line 26)
All arguments, except for the first one, must not be symbolic functions.
</pre><p>I want to derive a funtion woth respect to another function of time. And i even need the derivation of a function with respect to another derivative of a function of time.</p><p>I need this because I want to get the equations of motion of a system by using <a href = "http://en.wikipedia.org/wiki/Lagrangian_mechanics#Derivation_of_Lagrange.27s_equations">Lagrange equations of the second kind</a> .</p><p>Can anybody help me with this problem?
Thanks a lot.
Johannes</p>mistajojo/matlabcentral/answers/contributors/3795967-mistajojotag:www.mathworks.de,2005:Question/1598132014-10-23T13:20:17Z2014-10-23T14:14:25ZFilling data gaps in a periodic timeseries in MATLAB<p>I am looking for a method to fill in data gaps in a time-series that contains periodic data (in this case with a frequency equal to a tidal frequency, so both semi-diurnal and spring/neap frequencies) using MATLAB. The data series also contains noise which I would like to superimpose on top of the artificial data that fills the time gap. The data has a certain trend that I want to preserve. Ideally I would be looking at a method that uses the recorded data on either side of the time gap. The data files are too large to post here. However the sampling rate is 5 mins and there is approximately a week worth of data missing.</p><p><<</p><img src = "/matlabcentral/answers/uploaded_files/19896/Data_gap_zoom.png"><p>>></p><p>Is there anyway of doing this in Matlab?</p><p>Thank you.</p><p>Donald John</p>Donald John/matlabcentral/answers/contributors/3327612-donald-johntag:www.mathworks.de,2005:Question/1598272014-10-23T14:13:30Z2014-10-23T14:13:30ZI am doing some inegration with respect to (t) to find the Fisher Information but I need to check if my code is working correctely?<p>The code is:</p><p>function RunLogisticOscilFisher</p><p>omega=1;</p><p>k=10;</p><p>N0=1;</p><p>A=1;</p><p>p0=.1;</p><p>t=(0:0.001:10);</p><p>% Finding the numerical solution for the function using ode45 solver</p><p>[t,p]=ode45(@logisticOscilfisher,t,p0,[],N0,k,omega);</p><p>% Plotting the function with time</p><p>figure(1)</p><p>plot(t,p)</p><p>title('The function with Time')</p><p>xlabel('Time')</p><p>ylabel('The function')</p><p>% Defining my variable (p) as a function of (t)</p><pre> P=@(T) interp1(t,p,T); </pre><p>% Finding the integral to get the Fisher Information</p><p>f = @(T) ( ((25.*A.*(1./25).*sin(t).^4.*(10-2.*P(T)).^2)+cos(t).^2 )./(P(T).^2.*(10-P(T)).^2.*(sin(t).^4) ) )</p><p>I1=integral( f, 0,2,'ArrayValued',true)</p><p>I2=integral( f, 0,4,'ArrayValued',true)</p><p>I3=integral( f, 0,6,'ArrayValued',true)</p><p>I4=integral(f,0,8,'ArrayValued',true)</p><p>I5=integral(f,0,10,'ArrayValued',true)</p><p>I=[I1./2 I2./4 I3./6 I4./8 I5./10]</p><p>T=[2 4 6 8 10];</p><p>%Plotting the Fisher Information</p><p>figure(2)</p><p>plot(T,I); % axis([0 10 0.1 0.3])</p><p>title('The fisher Information')</p><p>xlabel('Time')</p><p>ylabel('FI values')</p><pre> 1;</pre><p>% function dpdt = logisticOscilfisher(t,p,N0,k,omega)</p><p>% dpdt = N0*sin(omega*t)*p*(1-p/k);</p><p>% end</p>Avan Al-Saffar/matlabcentral/answers/contributors/5297065-avan-al-saffartag:www.mathworks.de,2005:Question/1598262014-10-23T14:08:33Z2014-10-23T14:08:33ZMedian Inner Size Compact Boxplot<p>I have used the Compact plotstyle for matlab box plot and turned off the tags for box, outliers, and median outer. Essentially all I want to see is a straight line for the whisker and IQR and a black diamond or other symbol for the median. I have made some example data below with the code I have been using. The problem is that although the medianinner markers show up nicely in the fig window they print out very small in jpeg form. How do I get the medianinner markers to display in jpg like they do in fig???</p><p>Example Code;:
X = [2 4 3 6 4 3 12;3 6 4 2 15 8 5;2 2 3 1 5 19 4]';</p><p>figure</p><p>b = boxplot(X,'plotstyle','compact');
h1 = findobj(gca,'Tag','Outliers');
set(h1(:,:),'Visible','Off');
h2 = findobj(gca,'Tag','Box');
set(h2(:,:),'Visible','Off');
h3 = findobj(gca,'Tag','MedianOuter');
set(h3(:,:),'Visible','Off');
h4 = findobj(gca,'Tag','MedianInner');
set(h4(:,:),'LineWidth',5)</p><p>print boxplot.jpg -djpeg -r300</p><p>I am only interested in how to print this so it looks like the display in the figure window. I have tried increasing the size of the medianinner and this does not work. I have also tried making the medianouter bigger and then turning it off in case it was restricting the medianinner and this did not work either.</p>David/matlabcentral/answers/contributors/5810562-davidtag:www.mathworks.de,2005:Question/1596652014-10-22T12:55:26Z2014-10-23T14:07:35ZIs it possible to modify the matrices in a genss ?<p>Hello everybody!</p><p>Do you know if it's possible to change one of the matrices componing a genss (not only the tunable parameter) ?</p><p>For example the following system:</p><pre class="language-matlab">a = realp('a', 10); % The tunable parameter
A = [ 0 1; 1 a];
B1 = [1; 0];
B2 = [1 2; 0 1];
C = [1 1];
D = 0;
</pre><pre class="language-matlab">G = ss(A, B1, C, D);
</pre><p>Now I want to change the B matrix (to cope with more inputs for example) but I don't want to create a new genss (maybe I can't access A, C and D matrices, which could be much more complicated).</p><p>My question is: is it possible to change the B1 matrix by the B2 matrix in G ?</p><p>It's seems it's not even possible to access the A, B, C and D matrices of G except for the current value (but A won't be a genmat).</p><p>Does anybody have any idea ?</p><p>Thank you !
Stéphane</p>Stephane/matlabcentral/answers/contributors/1897664-stephanetag:www.mathworks.de,2005:Question/1598252014-10-23T14:04:43Z2014-10-23T14:04:43Zspeech recognition using svm<p>speech recognition using svm and genetic algorithm</p>imene s/matlabcentral/answers/contributors/5806441-imene-stag:www.mathworks.de,2005:Question/1598242014-10-23T14:03:43Z2014-10-23T14:03:43Zmex difference between mwPointer and pointer in Fortran90<p>What is the difference between <b>mwPointer</b> and intrinsic <b>pointer</b> in Fortran 90? Can you use mwPointer the way you would use an intrinsic F90 pointer?</p><p>Thanks
Rob</p>Robert/matlabcentral/answers/contributors/3219772-roberttag:www.mathworks.de,2005:Question/1250212014-04-08T18:50:14Z2014-10-23T14:03:20ZParallel computing corruption problem (Windows)<p>Hello,</p><p>I'm having a problem with parallel computing that is driving me nuts as I feel like I've exhausted all plausible causes. When I first installed matlab, parpool worked and I was able to run a parallel for loop. After that it didn't work and keeps failing with a long chain of errors.</p><p><i>Warning: Failed to remove the following invalid children under the profiles node:
local
> In NamedNodesCollection>NamedNodesCollection.refreshCache at 302
In NamedNodesCollection>NamedNodesCollection.refreshCacheIfRequired at 267
In NamedNodesCollection>NamedNodesCollection.getAllNames at 115
In Settings.Settings>iReplaceBadDefaultProfileWithLocal at 674
In Settings.Settings>Settings.hGetProperty at 148
In Settings.Settings>Settings.buildProperties at 629
In Settings.Settings>Settings.Settings at 324
In argumentsParser>iGetClusterAndNumWorkers at 112
In argumentsParser at 43
In parpool at 91
Warning: Failed to remove the following invalid children under the profiles node:
local
> In NamedNodesCollection>NamedNodesCollection.refreshCache at 302
In NamedNodesCollection>NamedNodesCollection.refreshCacheIfRequired at 267
In NamedNodesCollection>NamedNodesCollection.getAll at 59
In NamedNodesCollection>NamedNodesCollection.getAllNames at 116
In Settings.Settings>iReplaceBadDefaultProfileWithLocal at 674
In Settings.Settings>Settings.hGetProperty at 148
In Settings.Settings>Settings.buildProperties at 629
In Settings.Settings>Settings.Settings at 324
In argumentsParser>iGetClusterAndNumWorkers at 112
In argumentsParser at 43
In parpool at 91
Warning: Failed to remove the following invalid children under the profiles node:
local
> In NamedNodesCollection>NamedNodesCollection.refreshCache at 302
In NamedNodesCollection>NamedNodesCollection.refreshCacheIfRequired at 267
In NamedNodesCollection>NamedNodesCollection.nameExists at 107
In Settings.Settings>iReplaceBadDefaultProfileWithLocal at 695
In Settings.Settings>Settings.hGetProperty at 148
In Settings.Settings>Settings.buildProperties at 629
In Settings.Settings>Settings.Settings at 324
In argumentsParser>iGetClusterAndNumWorkers at 112
In argumentsParser at 43
In parpool at 91
Warning: The local profile cannot be found. Your installation might be corrupt.
Error using parpool (line 99)
The operation must modify one or more Settings files for these levels: factory, user, but you do not have write
permission on these levels: user.</i></p><p>I reinstalled matlab, and then it worked again the first time, but not again. Since then it hasn't worked even after reinstalling. Trying to open the cluster manager fails with error:</p><p><i>com.mathworks.jmi.MatlabException: The operation must modify one or more Settings files for these levels: factory, user, but you do not have write permission on these levels: user.
at com.mathworks.jmi.NativeMatlab.SendMatlabMessage(Native Method)
at com.mathworks.jmi.NativeMatlab.sendMatlabMessage(NativeMatlab.java:265)
at com.mathworks.jmi.MatlabLooper.sendMatlabMessage(MatlabLooper.java:120)
at com.mathworks.jmi.Matlab.mtFeval(Matlab.java:1541)
at com.mathworks.jmi.MatlabWorker.feval(MatlabWorker.java:197)
at com.mathworks.toolbox.distcomp.ui.profile.model.MatlabProfileManager$1.runOnMatlabThread(MatlabProfileManager.java:72)
at com.mathworks.jmi.MatlabWorker$2.run(MatlabWorker.java:79)
at com.mathworks.jmi.NativeMatlab.dispatchMTRequests(NativeMatlab.java:440)</i></p><p>I have full access to all of these places and matlab is not being very clear about what any of this means. I deleted the files that it generates in AppData/Roaming/Mathworks, but to no effect (I followed another post). All matlab-related folders have write permissions. I can't find any mention of this error while searching on Google so I'm completely stuck.</p><p>Does anyone have any idea what's going on?</p><p>Thanks!</p>Bogdan/matlabcentral/answers/contributors/3899132-bogdantag:www.mathworks.de,2005:Question/1597832014-10-23T07:59:44Z2014-10-23T13:58:44ZHow to delete specific lines from a txt file?<p>Hello, this is my problem:
Background: I am comparing 2 files that should match in the first column but one of the files skips some numbers, suppose (12,12), (13,13), (14,15)*, so until now I have use a code to find and display the mismatches on the screen and I manually delete the excess rows in the complete file and rerun the code until everything matchs.
Problem: Now usually I have used this with small files not correcting more than 10 mismatches, the problem is that I have a big data set with over 1000 of mismatches, so I need a way to delete the complete row of the "leftovers" in the txt file. Next is shown my coding:</p><pre class="language-matlab">%r is the number of total rows
%the first part is made for fileA and fileB storing in E and G matrices
fid = fopen('fileA.txt');
num_ints = 23;
num_rows = r;
format = [repmat('%f ', 1, num_ints)];
G = textscan(fid, format, num_rows);
G = [G{1:num_ints}];
fclose(fid);
</pre><pre class="language-matlab">for a = 1:1:r
if (E(a,1)~=G(a,1));
disp(E(a,1));
break
end
end
disp ('End of search');
</pre><p>As always thank you for your help!</p>Mario/matlabcentral/answers/contributors/4238010-mariotag:www.mathworks.de,2005:Question/1598232014-10-23T13:58:17Z2014-10-23T13:58:17ZHow to control a Release Gate with data computed in another Subsystem?<p>Hello everyone,</p><p>I am trying to do a traffic simulation with SimEvents (Matlab R2013b).
Since I have cars, that change their data continuously and entities, which are in a discrete event system I have to synchronize both parts. For a straight street my approach was to store the entities in a N-Server until the car has passed the straight and then let it out. The data of the car is stored in a matrix and each car has its own ID. Now the SimEvents system needs to check in the Matrix if the car already passed and then needs to open the release gate. If I try implementing this the function, which reads the memory matrix, is just executed once and the
I also tried using "Event To Timed Signale" Blocks before and after the function, which reads the memory. But then I get an algebraic loop error. If I break this loop with an delay, my data gets too old, which falsifies my simulation.
Do you have any ideas how to solve this? Is there a possibility to tell Simulink, to execute this function continuously?</p><p>Thanks for your help. I attached an example code.</p><p>Lucas</p>Lucas/matlabcentral/answers/contributors/3141362-lucastag:www.mathworks.de,2005:Question/1598222014-10-23T13:58:02Z2014-10-23T13:58:02ZVectorization of a for loop (addition of a vector)<p>Hello MATLAB community,</p><p>I have a question concerning the vectorization of a for loop to speed up my code.
What I have is a vector, let´s say:</p><pre class="language-matlab">a = [1 2 3 4 5 6 7 8 ]
</pre><p>What I want to do is to create a vector, which makes an addition of all values in the vector to the point which I am actually at. In this case it would be:</p><pre class="language-matlab">a_new = [1 3 6 10 15 21 28 36]
</pre><p>It´s no problem to code this with a for loop.</p><pre class="language-matlab">s_neu = zeros (1,length(s),'double');
</pre><pre class="language-matlab">s_neu(1,1) = s(1,1);
</pre><pre class="language-matlab">for i = 2:length(s)
</pre><pre> s_neu(1,i) = s_neu(1,i-1)+s(1,i);</pre><pre class="language-matlab">end
</pre><p>Do anyone of you know, how to code this without the for loop?
Thank you very much!</p>David/matlabcentral/answers/contributors/4226882-davidtag:www.mathworks.de,2005:Question/1598212014-10-23T13:53:52Z2014-10-23T13:53:52ZDoesn't Gap Evaluation work with "Hamming" metric?<p>Hello all,</p><p>I tried to use Gap Value to evaluate K-means clustering. It returns error</p><pre class="language-matlab">eva = evalclusters(x,'kmeans','gap','distance','hamming','KList',[1:6])
</pre><pre class="language-matlab">Warning: Clustering reference data into 1 clusters using function 'getKmeansFunc/nested' generated the following error:
Non-binary data cannot be clustered using Hamming distance.
> In GapEvaluation>GapEvaluation.evalFunXref at 406
In GapEvaluation>GapEvaluation.getRefLogW at 562
In GapEvaluation>GapEvaluation.GapEvaluation at 376
In evalclusters at 172
Warning: Clustering reference data into 2 clusters using function 'getKmeansFunc/nested' generated the following error:
Non-binary data cannot be clustered using Hamming distance.
> In GapEvaluation>GapEvaluation.evalFunXref at 406
In GapEvaluation>GapEvaluation.getRefLogW at 562
In GapEvaluation>GapEvaluation.GapEvaluation at 376
In evalclusters at 172
</pre><p>and so on and so forth.</p><p>The data is definitely binary, cause I have applied K-means clustering (Hamming distance) successfully to the same data. It just doesn't work, when I evaluated it with Gap statistic. Can you help me out here? Thanks a lot!!</p>betty/matlabcentral/answers/contributors/5810523-bettytag:www.mathworks.de,2005:Question/1595092014-10-21T13:07:57Z2014-10-23T13:53:11ZEPS export problems in R2014b<p>I have recently upgraded to R2014b (Linux version), and now exporting figures to eps seems to have a strange bug. If I try the following from the command line, I get the expected outcome.
plot(1:3,2:4);print(gcf,'-depsc', 'testFromCommandLine.eps');</p><img src = "/matlabcentral/answers/uploaded_files/19777/Screenshot%20from%202014-10-21%2014:56:40.png"><p>However, if I run the exact same script from the editor window, I get an eps file with a graph that occupies the top left corner of the canvas.</p><img src = "/matlabcentral/answers/uploaded_files/19778/Screenshot%20from%202014-10-21%2014:58:31.png"><p>The only code in the script is:
close all;
plot(1:3,2:4);
print(gcf,'-depsc', 'testFromScript.eps')</p><p>The screenshots of the two generated eps files are embedded.</p><p>This happens in all these three cases: pressing the RUN button in the editor, selecting the code and running the selection and executing the script (just typing the script's name without .m) from the command line.</p>Remco/matlabcentral/answers/contributors/2009221-remcotag:www.mathworks.de,2005:Question/1596502014-10-22T11:45:35Z2014-10-23T13:52:26ZI am plotting the logistic growth model using ode45,But I am confused because I am getting oscillation while I should get a constant line so do you think there is another routine could I use it or I need to change something to get the right plot??<p>The model is :</p><p>dxdt=N0*x*(1-x/k)</p><p>What I am doing is :</p><p>tspan=0:0.001:100;</p><p>x0=0.1;</p><p>[t,x]=ode45('funname',tspan,x0)</p><p>figure</p><p>plot(t,x)</p>Avan Al-Saffar/matlabcentral/answers/contributors/5297065-avan-al-saffartag:www.mathworks.de,2005:Question/1598202014-10-23T13:52:21Z2014-10-23T13:52:32Zgreat ways of solving geometry<p>great ways of solving geometry <a href = "http://www.reddit.com/r/hoymanyak/comments/2k3f7z/">http://www.reddit.com/r/hoymanyak/comments/2k3f7z/</a></p>katey roshek/matlabcentral/answers/contributors/5797782-katey-roshektag:www.mathworks.de,2005:Question/1598102014-10-23T12:38:55Z2014-10-23T13:52:14ZHow can put or place cursor a tex edit box in GUI without a mouse click?<pre> Hello,
I made a simple GUI . There is 2 text box in edit Style as Username and Password. But When I started GUI, I want to see cursor in Username Text box without any moose click.
regards,I couldn't success this for 2 days. Can you help me please.
Tevfik AKKUS</pre>Tevfik/matlabcentral/answers/contributors/5037071-tevfiktag:www.mathworks.de,2005:Question/1597992014-10-23T11:01:18Z2014-10-23T13:50:53Zrestore more than pixel values<p>how i can count and restore more than pixel values</p>yasser labeeb/matlabcentral/answers/contributors/5231275-yasser-labeebtag:www.mathworks.de,2005:Question/1598162014-10-23T13:35:27Z2014-10-23T13:49:00ZReading serial data continously<p>Hello,</p><p>I'm trying to read serial data from an Arduino with a sample time of about 50ms. I have configured a simple serial port and have no problem in communicating single packets either way.</p><p>But when I try to put my serial read in a loop it timeouts every 10th or so read. If I have timeout at 10 seconds the 11th read is successful (until about the 20th). If the timeout is at 1 second the 11th to 19th read is failed and the 20th to 29th is successfull and so on. So it seems to have to do with time which is very strange.</p><p>The code in it's simplest form:</p><pre> function [s] = Arduino_serial_0_3(comPort)</pre><pre class="language-matlab">s = serial(comPort);
set(s,'DataBits',8);
set(s,'StopBits',1);
set(s,'BaudRate',9600);
set(s,'Parity','none');
set(s,'Timeout',1);
set(s, 'terminator', 'LF'); % define the terminator for println
fopen(s);
for i = 1:20
pause(0.05);
input = fscanf(s,'%s');
disp(input);
end
fclose(s);
delete(s);
end
</pre><p>I have tried fread as well with similar results.</p><p>Please advise.</p>Martin/matlabcentral/answers/contributors/2013834-martintag:www.mathworks.de,2005:Question/1598192014-10-23T13:46:20Z2014-10-23T13:46:20Zmfilt.firdecim function not visible on Magnitude Response<p>Hello,
I'm quite new to Matlab. I'm trying to model a digital filter followed by a decimator. I've written:</p><pre class="language-matlab">num_fir1 = [1 4 6 4 1];
Hfir1 = dfilt.df1(num_fir1, 1);
Hdecim1 = mfilt.firdecim(2,num_fir1);
fvtool(Hdecim1,Hfir1)
</pre><p>I don't understand why the 2 filters Hdecim1, Hfir1 looks identical. I was expecting to see the aliasing effect on Hdecim1.</p><p>Thanks.</p>Francesco/matlabcentral/answers/contributors/5810314-francescotag:www.mathworks.de,2005:Question/1598182014-10-23T13:41:13Z2014-10-23T13:41:13ZError using mupadmex of syms<p>in th file here that is attached, this is the program that i am trying to run:</p><pre> syms t
syms j
K(t)=exp(-t);
F=1;
integrand(t,j) = K(t-j)*F;
U(t)=1 - int(integrand(t,j),j,0,t);
l=1;
h=l/10;
n=round(l/h);
Utest=zeros(1,n+3);
Uapp=zeros(1,n+3);
Kvector= zeros(1,n+3);
Fvector= zeros(1,n+3);
Integvector= zeros(1,n+3);
for i=1:n+1
Integvector(i)=int(integrand(t,j),j,(i-1)*h,i*h);
end;</pre><p>then i get the following error:</p><p>"The following error occurred converting from sym to double:
Error using mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead."</p><p>why is that?
how can i correct it so it will work right?</p>JACK/matlabcentral/answers/contributors/5810442-jacktag:www.mathworks.de,2005:Question/1598172014-10-23T13:39:27Z2014-10-23T13:39:27Zgriddata for closed surface<p>I have spherical data [theta, phi, R]: <i>R = f(theta, phi)</i></p><p>I need to interpolate this data. I've used griddata function and got a nice result, but with an
issue: it's not interpolated as a closed surface:</p><p>it looks like a rumpled orange (as I wanted), but there is no smooth seam line. So the data near edges are not interpolated as needed.</p><p>Is there any variants of griddata function for closed manifolds?
Or maybe some variants to solve this problem?</p>Evgheny/matlabcentral/answers/contributors/2228981-evghenytag:www.mathworks.de,2005:Question/1598082014-10-23T12:21:00Z2014-10-23T13:35:38Zerror running LAPACK with intel mkl with automatic offloads over Xeon phi<p>Hi,
I have set up a computer running on xeon E52600v2 and xeon Phi. I installed intel's mkl as it is explained in a tutorial by Intel such that matlab can automatically offload linear algebra routines (lu,cholesky,...) to the xeon phi.</p><p>I don't know if it is a xeon phi issue (I hope not and I don't think so) or a intel mkl issue but matlab crashes running the "bench" test routine when I have the following on my .profile:</p><p>#MKL
export MKLROOT=/opt/intel/mkl
export BLAS_VERSION=/opt/intel/composer_xe_2015/mkl/lib/intel64/libmkl_rt.so
export LAPACK_VERSION=/opt/intel/composer_xe_2015/mkl/lib/intel64/libmkl_rt.so
/opt/intel/composer_xe_2015/mkl/bin/mklvars.sh intel64
export MKL_MIC_MAX_MEMORY=16G
export MKL_MIC_ENABLE=1
#export OMP_NUM_THREADS=16
#export MIC_OMP_NUM_THREADS=240
#export OFFLOAD_REPORT=2 # the value 1 is also available
#export MIC_ENV_PREFIX=MIC
#export MIC_KMP_AFFINITY=granularity=fine,explicit,proclist=[1-240:1]
#export MIC_USE_2MB_BUFFERS=32K
#export MIC_MKL_DYNAMIC=false
#export KMP_AFFINITY=granularity=fine,scatter
#export OFFLOAD_DEVICES=0
#export OFFLOAD_ENABLE_ORSL=1
export LD_LIBRARY_PATH="/opt/intel/mic/coi/host-linux-release/lib:${LD_LIBRARY_PATH}"
export MIC_LD_LIBRARY_PATH="/opt/intel/mic/coi/device-linux-release/lib:/opt/inte/composer_xe_2015.0.090/compiler/lib/mic/:${MIC_LD_LIBRARY_PATH}"</p><p>I showed the commented environment variables as well as they might should have been uncommented?</p><p>I also join the matlab crash dump as attachment.</p><p>Anybody having an idea is my saver. :)</p><p>Thank you,</p><p>Jonathan</p>Jonathan Berrebi/matlabcentral/answers/contributors/1644721-jonathan-berrebitag:www.mathworks.de,2005:Question/1598152014-10-23T13:22:53Z2014-10-23T13:29:59Zhow to vectorize the following code?<p>Could anyone explain the steps?</p><pre class="language-matlab">DelayStep = 60;%in seconds
MaxStep = 86400;
for j=dStart:dEnd
currDay = datevec(j);
for k=0:DelayStep:MaxStep
hms = [0 0 0 fix(mod(k, [0, 3600, 60]) ./ [3600, 60, 1])];
UTCTimetoCalculate = datestr(hms+currDay);
</pre><pre> end
end</pre>UCL student/matlabcentral/answers/contributors/4746756-ucl-studenttag:www.mathworks.de,2005:Question/90702011-06-08T19:33:54Z2014-10-23T13:25:50Zimport user32.dll and use the 'BlockInput' function in it<p>Hi,</p><p>I am sending a series of keystrokes to the notepad application from Matlab and through the total process I would like to lock the user input form both keyboard and mouse till the process completes and then release the lock. I found that there is a function called 'BlockInput' MSDN function in 'user32.dll'. So I am trying to import this dll into Matlab and use the function but I am getting the following error when I am trying to load the dll using 'loadlibrary' command.</p><p>loadlibrary('"C:\WINDOWS\system32\user32.dll"','winuser');
Warning: The library class 'user32' already exists. Use
a classname alias.</p><p>Any guidance is appreciated.</p><p>Thanks,
Krishna.</p>Krishna/matlabcentral/answers/contributors/2808845-krishnatag:www.mathworks.de,2005:Question/1597772014-10-23T06:35:10Z2014-10-23T13:57:33ZWhy does legend patch turn black when using saveas?<p>Hi, I have a problem with the function <tt>saveas</tt> in matlab. The problem appears when I create a legend for more than one graph (eg 2 line graphs) in an image and then uses <tt>saveas</tt> on the figure. The problem is that when I try to use <tt>saveas</tt> (or <tt>publish</tt>, which uses <tt>saveas</tt>) on the image and the legend patch (the object named rectangle) is set to white, the patch turns black in the image (for me a .png image).</p><p>Since I wanted to set the background of the legend object to semi-transparent I had to remove the <tt>box</tt> and this causes some problems. The details will be seen in the example code. I am not sure whether there is a problem for all types of images, but I know it is at least a problem for .png images.</p><p><b>Have anyone seen this problem before and is it a known fix or workaround for it?</b></p><p><b>Example code:</b></p><pre class="language-matlab">publish('testScript');
</pre><pre class="language-matlab">function testScript()
figure;
plot(1:10,2:11,1:10,1:10,'r','LineW',2);
legend({'leg1','leg2'});
setLegendAlpha(0.9);
</pre><pre class="language-matlab">function setLegendAlpha( alphaValue )
hleg=findall(gcf,'tag','legend');
set(hleg,'box','off');
ch=findall(hleg,'type','axes');
ah=annotation('rectangle',get(ch,'position'));
set(ah,'facecolor','w','facealpha',alphaValue);
uistack(hleg,'top');
</pre><p>I am not sure if this problem is due to some error in the code in the function <tt>setLegendAlpha</tt> or if it is a bug. Also, if someone knows a workaround that does not cause the legend background to turn black when saving with <tt>saveas</tt> I would be happy. I can add that this problem cannot be seen in the figure and if I save it using <b>file->save</b> this problem is not seen either.</p><p>Matlab 2014a, windows 7</p>Patrik Ek/matlabcentral/answers/contributors/4360637-patrik-ektag:www.mathworks.de,2005:Question/1598142014-10-23T13:21:22Z2014-10-23T13:21:22ZCalculate 10y returns out of monthly data<p>hey guys,</p><p>i have monthly returns (1mil. simulations). Now i want to calculate corresponding 10 year returns.
for example vextor x:
0.05
0.02
0.03
0.4
-0.21
...</p><p>what matlab should do now is to calculate: ((1+r(1))*(1+r(2))*...(1+r(120)))-1
and ((1+r(121))*(1+r(122))*...(1+r(240)))-1 and so on...</p><p>thx for your help</p>Markus/matlabcentral/answers/contributors/4282820-markustag:www.mathworks.de,2005:Question/1598092014-10-23T12:37:36Z2014-10-23T13:07:08ZAnimating a sine wave movie<p>Hi guys
I would like to know how to make a movie of a sine wave using handle graphics and for each frame a for loop with getframe</p><p>a = -1; z = 0:pi/1000:2*pi;
y = a*sin(z)</p>tyler brecht/matlabcentral/answers/contributors/5574479-tyler-brechttag:www.mathworks.de,2005:Question/1588972014-10-16T16:55:47Z2014-10-23T13:03:43ZAdding subplots to animated gif file<p>Hi all,</p><p>I have the following code to create a gif from my data plots and I would like to do this with subplots for other parameters. The code is a bit messy but I am not sure how to work the handles for the subplots to have the playback synchronized for each plot:</p><pre class="language-matlab">DATASET1 = tower_pres_allyrs(1:100,1);
DATASET2 = tower_pres_allyrs(1:100,2);
</pre><pre class="language-matlab">h = plot(NaN,NaN);
axis([min(DATASET1) max(DATASET1) min(DATASET2) max(DATASET2)]);
</pre><pre class="language-matlab">for ii = 1:length(DATASET1)
pause(0.1)
set(h, 'XData', DATASET1(1:ii), 'YData', DATASET2(1:ii));
drawnow
frame = getframe(1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if ii == 1;
imwrite(imind,cm,'filename.gif','gif','Loopcount',inf,'DelayTime',0.01);
else
imwrite(imind,cm,'filename.gif','gif','WriteMode','append','DelayTime',0.01);
end
end
</pre><p>Thanks!</p>Masao Ashtine/matlabcentral/answers/contributors/4739967-masao-ashtinetag:www.mathworks.de,2005:Question/1597982014-10-23T10:58:05Z2014-10-23T13:00:03Zcomparing results of Kmeans algorithm with Database to find out The precision of algorithm<p>Hi, I have 2000 articles(2000 .txt files) from 20 subjects(20 Folders). it's my Database.</p><p>I clustered them by Kmeans Algorithm.("idx" parametr in Kmeans , shows me Each article belongs to which cluster)</p><p>Now , How can i compare Kmeans Result With Database to find out The precision of algorithm?</p><p>it's hard to use "Eye" for 2000 files!</p>Isay/matlabcentral/answers/contributors/3343989-isaytag:www.mathworks.de,2005:Question/1594842014-10-21T10:03:43Z2014-10-23T12:50:49ZInput data structure for classification NN<p>Hi, I am trying to perform image classification with a neural network. I have troubles formatting my input and I would like your advice :
My input consists of pixel clusters in an image. There are 3 clusters from every sample and each of them consists of a matrix with their coordinates. (each cluster is a collection of edges from my original image) It is a multiclass classification problem with 8 target classes.
I am trying to understand how to format them so they could be used as my input vectors but looking at examples has not helped very much. Any advice? (Perhaps represent these areas as a bitmap? like in the character recognition example? <a href = "http://www.mathworks.com/help/nnet/examples/character-recognition.html">here</a> )</p>S/matlabcentral/answers/contributors/3455863-stag:www.mathworks.de,2005:Question/1598062014-10-23T12:03:55Z2014-10-23T12:45:46ZSort Matrix by rows<p>I have a matrix which first row indicates index numbers and second indicated the data.
For example it goes like this:</p><pre class="language-matlab">1 2 3 4 5 6
23 45 10 90 11 34
</pre><p>I want to sort these descending but I don't want to loose the corresponding index either.</p><pre class="language-matlab">4 2 6 1 5 3
90 45 34 23 11 10
</pre><p>I have a large amount of data so it needs to be efficient too. How can I do that?</p>Ege/matlabcentral/answers/contributors/5717230-egetag:www.mathworks.de,2005:Question/1598032014-10-23T11:45:04Z2014-10-23T12:44:17ZHow to calculate the mean from different images at once? TBV1 and RVI1 cover each other and have the same size. in the following code I calculated thea mean of all the pixels of Tb where the condition applies.I have 3 more set of Tbv and RVI . <p>I need to calculate mean of all pixel of TBs where condition (RVI>=0 and RVI<=0.2)applies.my images are Tbv2,Tbv3,Tbv4 and RVI2,RVI3,RVI4.Please note that I dont want to calculate mean of each image seperately.the mean should be calculated at once for all images.</p><p>Tbv1 = imread('tb.tif');</p><p>RVI1 =imread('rvi.tif')</p><p>ME = mean(Tbv1( RVI1>=0 & RVI1 <=0.2));</p>Hana/matlabcentral/answers/contributors/5501063-hanatag:www.mathworks.de,2005:Question/1598112014-10-23T12:40:48Z2014-10-23T12:40:48ZSimulink Support Package for "Red Pitaya" hardware<p>Are there any plan to support the "Red Pitaya" hardware in the near future ?</p><p>When I can get an Simulink Support Package for Red Pitaya Hardware ?</p>Werner Fitzner/matlabcentral/answers/contributors/106392-werner-fitznertag:www.mathworks.de,2005:Question/1597652014-10-23T03:30:26Z2014-10-23T12:34:58ZHow to run multiple programs<p>Hi,</p><p>Anybody know a code to run (say) 3 programs one after another without having to give a command to run each program please?</p><p>What I want is something like the following</p><p>For i=1:3</p><p>test(i).m;</p><p>end</p><p>Thanks</p>dav/matlabcentral/answers/contributors/3693465-davtag:www.mathworks.de,2005:Question/1591602014-10-18T19:10:24Z2014-10-23T12:33:02ZHow to: Merging multiple graph lines<p>Hello Guys,</p><p>my problem is that I have several data sets of different x-Arrays and always the same y-Array. Basically my plot functions looks like this: plot(x1,y,'g',x2,y,'b'....)</p><p>As I have drawn in the picture I want to merge all the lines as to always keep the lowest y-values going from left to right in terms of x-values. This should creat one single new plot that looks like the black line in the right picture. The left picture demonstrates the overlapping data sets.</p><p>Can I solve this problem graphically, e.g. using a plotting function to always display the lowest y-value or do I need to create a new 2D array that always picks the lowest y-value for every x- value? Maybe you can give me a base to start from. Sorry about my "untechnical" explanation, Im new to Matlab and coding in general.</p><p>Thanks in advance for your support.
Pat</p>Patrick/matlabcentral/answers/contributors/1432907-patricktag:www.mathworks.de,2005:Question/770392013-05-26T21:58:01Z2014-10-23T12:29:38ZComparing strings with wildcards<p>Hi,</p><p>I have a number of strings that I'd like to check for a certain ending however the middle of the strings are all different (the middle of the strings are dates). They are of the format:
wrfout****_PLEV or wrfout****
where <b>**</b> is the date (all dates are of the same length). I basically want to find the strings that do not have _PLEV at the end.</p><p>I've tried using strcmp with wildcards but for some reason the creators decided it was a fantastic idea to ignore wildcards altogether which in my opinion negates a lot of potential uses of the strcmp function.</p><p>I've also tried using strncmp but that only allows you to specify the first n letters of a string to compare and not the last.</p><p>I then tried using simple inequalities, to obtain exactly which characters are the same, such as:
'wrfout****_PLEV == wrfout****
but as expected the different lengths of the strings prevented me from using this idea.</p><p>Any ideas as to how to do this or how to compare strings with wildcards would be very useful?</p><p>Thanks in advance
James</p>James/matlabcentral/answers/contributors/3058375-jamestag:www.mathworks.de,2005:Question/1596672014-10-22T13:16:10Z2014-10-23T12:27:03ZProgram NXT to write/draw in MATLAB<p>Hi guys. I was wondering if anyone knew how to program the NXT to write/draw. I have programmed the NXT motors to drive and the writing arm to go up and down. But I have no idea how to program it to write a word or to make it draw vectorized images. I would really appreciate some help.</p><p>Thanks in advance</p>Nourhan/matlabcentral/answers/contributors/5538751-nourhantag:www.mathworks.de,2005:Question/1597602014-10-23T01:39:34Z2014-10-23T12:24:29ZPlotting the convolution of two signals<p>I am given two functions x(t) =5[u(t+1)-u(t-1)] and h(t)=u(t-1)-u(t-7). I am asked to convolve these two signals and plot the result in the range -3 to 10. Here is the code that I wrote:</p><p>t=-3:0.1:10;
t_c=-3:0.05:10;
h_t=heaviside(t-1)-heaviside(t-7);
x_t1=5.*(heaviside(t+1)-heaviside(t-1));
c_x_h=conv(x_t1,h_t);
figure(1)
plot(t_c,c_x_h)</p><p>However, since this is a simple convolution I verified it by hand and it does not look like the plot i get in MATLAB. The max value should be 10 but in MATLAB i get 100. Also, the duration of the function should be 8 but i get 4 with MATLAB. Please help.</p>Dennis/matlabcentral/answers/contributors/5808305-dennistag:www.mathworks.de,2005:Question/1596742014-10-22T13:59:24Z2014-10-23T12:11:20ZProgram to control acceleration of a car<p>Hello, I am trying to create a program to control the acceleration of a car. The car has accelerate up to the speed limit or the car in front of it, which ever is slower and decelerate to avoid a collision if necessary. There are comfortable limits for deceleration and acceleration.</p><p>The first test case is the simplest and involves accelerating up to meet a car and then following it. I can get up behind it, but my acceleration and deceleration oscillate extremely. The graph of acceleration bounces back forth between the max and min acceleration..</p><p>How can I fix this?</p><pre class="language-matlab">if true
% code
% D(n) is the distance to the car in front at time n
% VL is the velocity of the lead car
% V(n) is the velocity of the car at time n
</pre><pre> if D(n)>(8*V(n)) % accel comfortably until within 8sec of car in front
a=AccelLimit;
elseif(VL-V(n))<0
a= min((100/((D(n))))*((VL-V(n))/dt),AccelLimit);% if the car in front is going slower, we want our deceleration to be proportional to diff in VL-V(n) and inverse to D(n)
elseif D(n)<1
a=DecelLimit;
else
a=min((0.01*(D(n))*((VL-V(n))/dt)),DecelLimit); % if the car in front is going faser, we want our acceleration to be proportional to D(n) and VL-V(n)</pre><pre> end
end</pre><p>Thanks!</p>Ryan/matlabcentral/answers/contributors/5591446-ryantag:www.mathworks.de,2005:Question/1581492014-10-10T13:25:34Z2014-10-23T12:07:36ZI want to transmit and recieve audio using PSK modulation<p>i am doing a small project on transmission and receiving of Audio file using PSK modulation please help me out</p>kedarsai padigala/matlabcentral/answers/contributors/5755212-kedarsai-padigalatag:www.mathworks.de,2005:Question/1598072014-10-23T12:06:26Z2014-10-23T12:06:26ZControl Point Registration with Matlab<p>Hello,</p><p>I'm new to Matlab and I'm trying to do a Control Point Registration using your guide: <a href = "http://www.mathworks.com/help/images/point-mapping.html">http://www.mathworks.com/help/images/point-mapping.html</a></p><p>The result I get is two pictures one on top of the other but they are misaligned .</p><p>Can you please tell me what am I doing wrong ?</p><p>Thank you.</p><p>Here is the code:</p><pre class="language-matlab">function [Y] =EBL
</pre><pre> ReferenceImg=imread('GFI.jpg'); %This is the fixed image
CroppedImg=imcrop(ReferenceImg); %Crop fixed image
close %close the imcrop window
MovingImg = imread('GF.bmp'); %This is the moving picture</pre><pre> ResizedIReferenceImg= imresize(CroppedImg,[1000 1000]); %resize the fixed image
ResizedMovingImg= imresize(MovingImg,[1000 1000]);%resize the moving image</pre><pre> [input_points,base_points] = cpselect(ResizedMovingImg,ResizedIReferenceImg,'Wait', true);%Estimate transformation</pre><pre> tform = fitgeotrans(input_points,base_points,'projective');</pre><pre> B = imwarp(ResizedMovingImg,tform);</pre><pre> imshow(B)
hold on
t=imagesc(ResizedIReferenceImg);%Set transparency of fixed image
set(t,'AlphaData',0.5);</pre><p>end</p>Yulia/matlabcentral/answers/contributors/5721216-yuliatag:www.mathworks.de,2005:Question/1594882014-10-21T11:01:21Z2014-10-23T12:04:38Zproblem with cellular automata code?<p>i found this code here, and i try to initialize it with [1 0 1 1 0 1 1] but it didn't work.</p><p><a href = "http://www.mathworks.com/matlabcentral/fileexchange/39492-ca-code-for-matlab/content/wolfram.m">http://www.mathworks.com/matlabcentral/fileexchange/39492-ca-code-for-matlab/content/wolfram.m</a></p><p>the code is long to paste it here.
and how to locate the image?</p>sara/matlabcentral/answers/contributors/5790085-saratag:www.mathworks.de,2005:Question/1598052014-10-23T11:56:30Z2014-10-23T12:03:26ZMATLAB R2014b does NOT work when using Mac OS X 10.9.5<p>Hi</p><p>This will be a general question but I am really getting tired of this not running problem..</p><p>Could you please help me why matlab does not run after a while</p><p>Evenif I did not make a change in my codes, it just stops working</p>Meva/matlabcentral/answers/contributors/4934134-meva