http://www.mathworks.de/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2014-09-01T23:05:16Ztag:www.mathworks.de,2005:Question/1531092014-09-01T22:25:19Z2014-09-01T23:05:16ZNumber greater than the largest positive floating-point number (1.7977e+308)<p>I'm trying to calculate the following expression:</p><p>(l+m)! / (l!m!)</p><p>but when l=m > 85 I get infinity, because the result is greater than the largest positive floating-point number (1.7977e+308).</p><p>Is there a way of increasing this number limit, or even a trick to avoid this problem?</p>Tigo/matlabcentral/answers/contributors/5560534-tigotag:www.mathworks.de,2005:Question/1531032014-09-01T20:49:58Z2014-09-01T22:52:00Zhow to set the ticks in the colorbar to be automatic and as many as possible?<p>i'm trying to use as many ticks in the colorbar
doing so manualy lead to unexpected resault such as:</p><img src = "/matlabcentral/answers/uploaded_files/17661/Screenshot%202014-09-01%2023.48.02.png"><p>(in the attached image)</p><p>i used:</p><pre class="language-matlab">cbr=colorbar('fontsize',15);
set(cbr,'YTick',min(min(MAT)):max(max(MAT))/100:max(max(MAT)))
</pre><p>how can i still get as many ticks as possible but still keeping the data readable</p>Kobi/matlabcentral/answers/contributors/3268302-kobitag:www.mathworks.de,2005:Question/1531102014-09-01T22:29:59Z2014-09-01T22:29:59ZHow to read file '04015.dat','04015.atr' and '04015.qrs' of MIT BIH AF Database(PHYSIONET)<p>By using the rddta.m file i can read the ecg signal from mit bih arrhythmia database.But in mit bih AF data base there are two ecg signals in a single dat file.but i badly need to read data from those files.So can any one please give me a code or suggest me how can i modify the rddta.m to read data from mit bih AF database.</p>Mahdi/matlabcentral/answers/contributors/5579219-mahditag:www.mathworks.de,2005:Question/1530942014-09-01T19:30:07Z2014-09-01T22:29:30ZStop/Delete Timer Issues While Closing GUI<p>Hi,</p><p>I use a timer to update an axes in a GUI. I want to handle the case in which the user closes the window while the timer is still running, i.e., the axes still beeing updated.</p><p>The Problem:</p><p>However, every so often the execution time of the TimerFcn is longer than the timers period (depending on the pc's performance). This can cause an error when closing the GUI while the timer is still running.</p><pre> Error while evaluating TimerFcn for timer 'timer-1'</pre><pre> Bad handle</pre><p>FYI, I use</p><pre> T = timerfind;
if ~isempty(T)
stop(T)
delete(T)
end</pre><p>in the figure's delete function. Apparently, the TimerFcn is still being called after the execution of the figure's delete function. Hence, within my TimerFcn an error occurs during a call to</p><pre> cla(myaxes),</pre><p>for cla expects a valid figure handle (though the GUI's figure has just been deleted).</p><p>All in all, it seems that the execution time being larger than the timer period is causing this. Of course I could reduce the timer period, but this is not desirable. I figured out a workaround by using a try-catch phrase within the TimerFcn, however it's not a proper solution.</p><p>Question:</p><p>Is there any way to force the TimerFcn to stop and somehow flush its executin queue/event buffer, regardless of its current state? Any thoughts about solving this issue are very welcome!</p><p>Thank you in advance!</p><p>Hannes</p>Hannes/matlabcentral/answers/contributors/5554056-hannestag:www.mathworks.de,2005:Question/1530612014-09-01T13:30:01Z2014-09-01T22:27:31Zhow can i make a change in my image ?<p>hi guys .
i have an image (257*161) .</p><p>im = f(x,y)</p><p>how can i change my image equation to im = f(x/8 , y/12 )</p><p>could you please help me ?</p><p>thanks</p>hamed/matlabcentral/answers/contributors/3810756-hamedtag:www.mathworks.de,2005:Question/1531082014-09-01T22:13:01Z2014-09-01T22:13:01ZInner join() Producing Duplicate Entries<p>I have several large times series of meteorological variables from the same measurement tower. I wanted to compare data values as the exact same measurement points in time. I setup serial date numbers and values into <tt>dataset()</tt> arrays similar to the following post:</p><p><a href = "http://www.mathworks.com/matlabcentral/newsreader/view_thread/310964">Match Time Series by Time Vector</a></p><p>I followed Message 5 to code something like <tt>C = join(Dataset1, Dataset2, 'Type', 'inner')</tt>. The results looked good at first input dates like the following:</p><pre class="language-matlab">[DS1.Time DS2.Time] =
01-Jan-2012 00:07:22 01-Jan-2012 00:07:22
01-Jan-2012 00:17:22 01-Jan-2012 00:17:22
01-Jan-2012 00:37:22 01-Jan-2012 00:37:22
01-Jan-2012 00:47:22 01-Jan-2012 00:47:22
01-Jan-2012 00:57:22 01-Jan-2012 00:57:22
01-Jan-2012 01:47:22 01-Jan-2012 01:07:22
01-Jan-2012 01:57:22 01-Jan-2012 01:27:22
01-Jan-2012 02:07:22 01-Jan-2012 01:47:22
01-Jan-2012 02:17:22 01-Jan-2012 01:57:22
01-Jan-2012 02:27:22 01-Jan-2012 02:07:22 ...
</pre><p>so that the resulting dates (with data) using <tt>C = join(DS1,DS2,'Type','inner')</tt> would be:</p><pre class="language-matlab">C.Time =
01-Jan-2012 00:07:22
01-Jan-2012 00:17:22
01-Jan-2012 00:37:22
01-Jan-2012 00:47:22
01-Jan-2012 00:57:22
01-Jan-2012 01:47:22
01-Jan-2012 01:57:22
01-Jan-2012 02:07:22
01-Jan-2012 02:17:22
01-Jan-2012 02:27:22 ...
</pre><p>The problems started when I would take the output <tt>C</tt> to perform more time series merging. From and inner join being like and intersection of the times in two datasets, it stands to reason that <tt>length(C) <= length(DS1)</tt> and <tt>length(C) <= length(DS2)</tt>. This became not the case using <tt>Cnew = join(C,DS4,'Type','inner')</tt>. Checking the times on the ends looked fine, but I finally discovered repeated data rows in the middle of the resulting dataset like:</p><pre class="language-matlab">Cnew.Time =
...
02-Nov-2012 09:50:11
02-Nov-2012 09:50:11
02-Nov-2012 09:50:11
02-Nov-2012 09:50:11
02-Nov-2012 09:50:11
02-Nov-2012 09:50:11
02-Nov-2012 09:50:11
02-Nov-2012 09:50:11
02-Nov-2012 09:50:11
02-Nov-2012 09:50:11
02-Nov-2012 09:50:11 ...
</pre><p>After much investigation, the only way I found to fix this problem after an inner join was to use the <tt>unique()</tt> function in the following way:</p><pre class="language-matlab">Cnew = join( C, DS4, 'key', 'Time', 'Type', 'inner', 'MergeKeys', true ) ;
CnewUnique = unique(Cnew , 'Time') ;
</pre><p>This would finally produce the output I was looking for:</p><pre class="language-matlab">CnewUnique.Time = ...
02-Nov-2012 09:00:11
02-Nov-2012 09:10:11
02-Nov-2012 09:20:11
02-Nov-2012 09:30:11
02-Nov-2012 09:40:11
02-Nov-2012 09:50:11
02-Nov-2012 10:00:11
02-Nov-2012 10:10:11
02-Nov-2012 10:20:11 ...
</pre><p>This took <b>many</b> hours to figure out so I wanted to ask the following question(s):</p><ol><li>Why was the <tt>join(...,'inner',...)</tt> not working the way I expected, as it did before?</li><li>Is there a better way to match up the times from several time series? (I did not have success with the <a href = "http://www.mathworks.com/help/matlab/ref/timeseries.synchronize.html">synchronize</a> function either for an "intersection" of the times.)</li><li>Has anyone else had a similar problem? Is Matlab possibly having a "bug"-type behavior here?</li></ol><p>Any insights are appreciated. Thank you for contributing this this post.</p>Paul Quelet/matlabcentral/answers/contributors/4012500-paul-quelettag:www.mathworks.de,2005:Question/1531072014-09-01T22:05:32Z2014-09-01T22:05:32ZHow can i get data with getdata but when i got some number of samples i can use it in other function while i am getting others sample?<p>I want to get data with getdata function but when i use it, i have to wait until the function get all samples, I want to know if can i use this function and when i get some number of samples I can use it in others function and continus with the adquisition without problem</p><p>Regards</p>Jesus/matlabcentral/answers/contributors/1671943-jesustag:www.mathworks.de,2005:Question/1531062014-09-01T22:01:58Z2014-09-01T22:01:58Zhelp in p code<p>good evening everybody</p><p>my question is how can I add a help within a p code ?</p><p>thanks in advance</p>XAXRXTX/matlabcentral/answers/contributors/4836391-xaxrxtxtag:www.mathworks.de,2005:Question/1531042014-09-01T20:59:33Z2014-09-01T21:50:35Zcalculation of observable area of an airplane?<p>I have an application where I need the observed equivalent area of an airplane in an arbitrary orientation. That is if the observer is directly under the AC the area would simply the be the 3-view top area, but what if the observer were 45deg behind the right wing and 30deg below the horizontal plane of the AC? I have been using an approximation that ignores wing area-this is no longer sufficient.</p><p><a href = "http://en.wikipedia.org/wiki/Projected_area">wikipedia</a> has an ok article, by extension I could sum the three areas each corrected by cos(beta). But does not account for when one surface is partly hiding a second surface.</p><p>Currently I am using a simple method given 2d area and observed angle (cos(beta) effectively), I would consider a method that required 2d surface point definitions for top/left/fore.</p><p>Run time is not critical, provided I can sweep it into a 2d data table (range is handled by other means).</p><p>Any direction or key words to search on would be appreciated. thanks.</p>chris/matlabcentral/answers/contributors/5389725-christag:www.mathworks.de,2005:Question/1531052014-09-01T21:49:09Z2014-09-01T21:49:09ZTime simulation with FRD model<p>Hello</p><p>I have a FRD model of a linear system. Is it possible to use it to run time simulations to an input I will define in time domain?</p><p>Thanks</p>Michele/matlabcentral/answers/contributors/5351676-micheletag:www.mathworks.de,2005:Question/1257272014-04-14T16:03:11Z2014-09-01T21:31:24ZHow to apply Kalman filter on time series? <p>I have time series from stock market and want to apply the Kalman Filter. I read the samples about the setup of the Filter and they all work with some kind of matrizes. The command dspadpt3 gives me some weird mask which I have no conlcusion about handling it.</p><p>So, my main purpose would be so apply the Filter on a time series and see how it is adapted resp. hulled in (var resp. covar?).</p><p>Is there a hint resp. sample how to start the stuff? (e.g. how to get the matrixes, how to continue for a plot, etc.)</p>Leo/matlabcentral/answers/contributors/5217676-leotag:www.mathworks.de,2005:Question/1530352014-09-01T08:15:15Z2014-09-01T21:12:56Zanimation : movie + comet in one figure (subplots)<p>Hi, I would like to plot two different animations in one figure. One the one hand I have a comet plot:</p><pre class="language-matlab">comet(data.pg{1,1});
</pre><p>And then I have an animation of a bar plot:</p><pre class="language-matlab">axis tight manual;
set(gca,'NextPlot','replaceChildren');
for i = 1:length(emg2{1,1})
extensors = [emg2{1,1}(i,1:5);emg2{1,1}(i,6:10);emg2{1,1}(i,11:15);emg2{1,1}(i,16:20);emg2{1,1}(i,21:25);emg2{1,1}(i,26:30);emg2{1,1}(i,31:35);emg2{1,1}(i,36:40);emg2{1,1}(i,41:45)];
bar3(abs(extensors))
F(i) = getframe;
end
movie(fig,F,1)
</pre><p>Now I want both animations to run at the same time and in the same figure but in subplots. I used a code but it doesn't work. Can anybody help ?</p><pre class="language-matlab">axis tight manual;
set(gca,'NextPlot','replaceChildren');
for i = 1:length(emg2{1,1})
subplot(1,2,1);
extensors = [emg2{1,1}(i,1:5);emg2{1,1}(i,6:10);emg2{1,1}(i,11:15);emg2{1,1}(i,16:20);emg2{1,1}(i,21:25);emg2{1,1}(i,26:30);emg2{1,1}(i,31:35);emg2{1,1}(i,36:40);emg2{1,1}(i,41:45)];
bar3(abs(extensors))
subplot(1,2,2);
comet(data.pg{1,1});
F(i) = getframe;
end
movie(F,1)
</pre>N/matlabcentral/answers/contributors/4790141-ntag:www.mathworks.de,2005:Question/1527672014-08-29T12:40:35Z2014-09-01T20:57:33Zxcorr and time lag<p>Hi all,</p><p>I have a simple, but yet I can't seem to figure it out, question about crosscorrelation.When I find my maximum crosscorrelation, I want to find the corresponding time lag.
What I have in code so far:</p><pre class="language-matlab">x = [0 0 1 5 1 -2 -3 -2 0 0];
y = [0 0 1 5 1 -2 -3 -2 0 0];
X2 = xcorr(x,y,'coeff'); (so we expect a xcorr of 1 because its the same signal)
plot(lags,C)
[val,idx] = max(abs(C))
</pre><p>Now it says that the maximum crosscorrelation (1) is at time lag 10. now I get that because the time series goes from -9 till +9, so step 10 is at zero-lag, but how can I get as answer the zero and not 10. So I want the real value of time lag and not the amount of steps.</p><p>Later on I would actually want to make the time lags correspond to real time as well ,so for example a lag of 1 equals to 2 seconds, which is the reason I want the amount and not the steps so I know how many seconds really passed. How can I do this also, so make the time lag correspond to real seconds?</p>N/matlabcentral/answers/contributors/4790141-ntag:www.mathworks.de,2005:Question/1529472014-08-31T07:27:40Z2014-09-01T20:57:08ZFinding best neural network structure using optimization algorithms and cross-validation<p>Hi.</p><p>I'm using optimization algorithm to find best structure+inputs of a 'patternnet' neural network in MATLAB R2014a using 5-fold cross validation. Where should i initialize weights of my neural network?</p><pre> *Position_1(for weight initialization)*</pre><pre> for i=1:num_of_loops
*Position_2(for weight initialization)* </pre><pre> - repeating cross validation
for i=1:num_of_kfolds
*Position_3(for weight initialization)*
- Cross validation loop</pre><pre> end
end</pre><p>I'm repeating 5-fold cross validation (because random selection of cross validation) to have more reliable outputs (average of neural network outputs). Which part is better for weight initialization (Position_1,Position_2 or Position_3) and why?</p><p>thanks.</p>Jack/matlabcentral/answers/contributors/5193869-jacktag:www.mathworks.de,2005:Question/1531012014-09-01T20:30:17Z2014-09-01T20:57:04ZI need to make a computation that will return the answer with units. <pre> I wrote several programs with will make my desired computations successfully. my problem arises when I try to add a line that will allow the user to type in the units (feet for example) used then return that unit squared Ft^2 or square feet.</pre><p>I have a program with will compute the area of a square successfully .</p><pre> X=hight
y=base
fprintf (the area is %d \n x*y)</pre><pre> this program will return the area but i need to have units after the number (ft^2) and I need for the user to choose the units. </pre>daniel/matlabcentral/answers/contributors/5574603-danieltag:www.mathworks.de,2005:Question/1529302014-08-30T21:20:30Z2014-09-01T20:50:49Zvalues of randi function repeat themselves<p>while using the function randi that generate random integers uniformly disterbuted i sometimes get in the output vector the same numbers
for example:</p><p>4 2 5 3 4 8 7 9 7 4</p><p>(the number 4 was three times in the row above)</p><p>how can i avoid this?</p><pre class="language-matlab">locTX=randi([1 20],1,4);
</pre>Kobi/matlabcentral/answers/contributors/3268302-kobitag:www.mathworks.de,2005:Question/1530762014-09-01T15:32:19Z2014-09-01T20:46:25ZStatus for forum members: who would use/care for it?<p>Dear all,</p><p> I am well aware that the TMW forum is not Skype or gChat, but, while traveling for an extended period of time, I would be happier if I had been able to change my/some "status for the TMW forum" to "Traveling until mid-September", rather than just disappearing without leaving a note.</p><p>Hence my question (before I submit something to TMW): if there was a status field in users' profiles, would you use it and/or care for it?</p><p>Best wishes,</p><p>Cedric</p>Cedric Wannaz/matlabcentral/answers/contributors/1078046-cedric-wannaztag:www.mathworks.de,2005:Question/1530222014-09-01T03:59:07Z2014-09-01T20:41:41ZMatlab very slow at initialization and execution. Why?<p>Hi,</p><p>I recently upgraded my matlab version to 2013a from 2011. I had a network license earlier and now a license key. I have a mac (Mavericks - 10.9.4) and uninstalled 2011 before I installed 2013a. But every since its installation, matlab has become extremely slow. It takes a really long time for initialization (approx 5 mins after opening the window) and then a very long time every time I run simple commands (like print a 2x2 matrix that I just defined). I also upgraded to JAVA (jdk and jre) to 1.7 version.</p><p>Thanks,
PH</p>Pavithra/matlabcentral/answers/contributors/2357755-pavithratag:www.mathworks.de,2005:Question/1530962014-09-01T19:48:28Z2014-09-01T20:39:39Zdrawing simple 3d vectors without manual inputing values <p>I have tried to find the answer to this but have not found explicitly what I'm looking for</p><p>All i want to do is define 2 vectors</p><pre class="language-matlab">a = [6,-8,2]
b = [4,6,12]
</pre><p>I want to plot in 3d</p><pre class="language-matlab">a+b
a-b
dot(a,b)
cross (a,b)
</pre><p>I have seen how to do it in mupad
and i know you can use quiver3 but you have to manual input the points such as</p><p>"quiver3(x,y,x,u,v,w)"
I want to be able to say
quiver3("the name of the vector)
and be done</p><p>How do i do this? Maylab is extremely powerful yet in all my searching i can not find the ability to simply plot 3 lousy R3 vectors</p><p>If someone could explain a simple way of what i want to do that would be great
Thank you!</p>Robert/matlabcentral/answers/contributors/2986565-roberttag:www.mathworks.de,2005:Question/1531022014-09-01T20:39:36Z2014-09-01T20:39:36ZHow can I compile a shell application from which to launch one of three sub-applicaions<p>I have three GUIs that I would like to run from a master GUI as a single stand-alone .exe file. Each of the three GUIs runs fine and I can compile and run them individually as .exe files. I can run the master GUI from the .m file and it will also run fine and I can access the three sub-GUIs from that master GUI.</p><p>But, when I try to compile the master GUI into a .exe file, it will not run (nothing happens after I double-click the application icon). There are no errors reported during the compile. Is it possible to setup this sort of shell application that gives the user the option of selecting which sub-GUI to run?</p>Joel/matlabcentral/answers/contributors/4807356-joeltag:www.mathworks.de,2005:Question/1530342014-09-01T07:58:40Z2014-09-01T20:32:38ZHow to convert multiple date formats in a loop?<p>I am processing data from an instrument, where the time read out is something like this-</p><p>'29/08/2014 14:31'</p><p>'31:41.0'</p><p>'31:41.1'</p><p>'31:41.1'</p><p>Where the full date stamp repeats around every 20 readings, but this isn't constant, so I cannot just select the data every 20th reading.</p><p>However, when using datestr on the '31:41.0' type readings, it comes out as the 1st January 2014 00:31:41.0.</p><p>I have a method of converting '31:41.0' readings to the correct date by taking the difference between the first long reading and the 1st Jan 2014 datenums and then using add time to correct for the minutes but only for one cell at a time.</p><p>What I would like to do is loop through the data and do something like;</p><p>if date stamp is in the long format- use method 1- datenum(data(1,1),'dd/mm/yyyy HH:MM')</p><p>else, use method 2</p><p>so I end up with a new column of the correct datenums.</p><p>The size of the matrix does vary for the filesets.</p><p>I have no idea how to go about this, so any help and suggestions would be appreciated.
Thanks!</p>Hannah/matlabcentral/answers/contributors/3116496-hannahtag:www.mathworks.de,2005:Question/1529982014-08-31T22:37:49Z2014-09-01T20:09:23Z different color for different region of image<p>Hi
I have an image, I wonder how to assign different color for different region in the image?
For example how can I choose one colormap for blue rectangle and one colormap for green rectangle and the rest of figure uses different colormap.</p><img src = "/matlabcentral/answers/uploaded_files/17627/cropedimage.jpg">chess/matlabcentral/answers/contributors/3704367-chesstag:www.mathworks.de,2005:Question/1531002014-09-01T20:07:56Z2014-09-01T20:08:41ZSimulink MxArray for logical array<p>'function [ index] = SoftMax( Q )</p><p>coder.extrinsic('softmax');</p><p>Temperature = 0.5;
terms = Q/Temperature;</p><p>Prob = softmax (terms);</p><p>cummu = cumsum (Prob);</p><p>randm = rand();</p><p>index= sum(cummu <= randm) +1;'</p><p>Dear MATLAB community,</p><p>I am using this code on MATLAB Function block in Simulink. 'Q' is an array which made 'cummu' an array too. Running this function at MATLAB command windows doesn't have problems, but running in Simulink returns "Expected either a logical, char, int, fi, single, or double. Found an mxArray. MxArrays are returned from calls to the MATLAB interpreter and are not supported inside expressions. They may only be used on the right-hand side of assignments and as arguments to extrinsic functions." for 'index= sum(cummu <= randm) +1;'</p><p>I have also tried</p><p>'for i = 1:numel(Q)
if(randm >= cump(i))
action = action +1;
end
end'</p><p>but it returns "Subscripting into an mxArray is not supported. ... ... cummu (i)... ..."</p><p>I am stuck on this, please help. Thank you!</p><p>Tan Biru</p>Tan Biru/matlabcentral/answers/contributors/5539082-tan-birutag:www.mathworks.de,2005:Question/1530982014-09-01T19:58:54Z2014-09-01T20:07:44ZArea of a square with units<p>Write a computer program that can calculate the cross-sectional areas for a square. The program should allow the user to enter the dimensions SI
and ips units, and give the results in both systems as well.</p>daniel/matlabcentral/answers/contributors/5574603-danieltag:www.mathworks.de,2005:Question/1267812014-04-23T06:00:01Z2014-09-01T20:06:55Zhow to label text using connected component and then find the horizontal and vertical projection and then segment the text from the image using otsu threshold and morphological operation in matlab.<p>fistly, I applied canny to detect edges and i want to find connected components and label them in rectangular boxes. After that i want to get horizontal and vertical histogram and apply horizontal and vertical projection profile. For segmenting the text from the the background i want to apply otsu threshold and morphological operation in matlab. I tired this but doesnot get the exact result. Can someone give the exact code for that.</p>aditi/matlabcentral/answers/contributors/5133685-adititag:www.mathworks.de,2005:Question/1530992014-09-01T20:03:45Z2014-09-01T20:03:45Zplotting eye diagram in matlab<p>I have an ideal 16 Gbps PRBS 7 NRZ signal which I have generated in Matlab using stairs function. I have the x and y columns having time and actual signal values. I have a NRZ_data variable having x values in 1st column and y values in 2nd column. By using eyediagram(NRZ_data,127), I am expecting an eye diagram in only one unit interval. But, I am not getting a proper eyediagram. Please can someone tell me how can I get a proper eye diagram of 16 Gbps PRBS 7 NRZ signal?</p><p>Best Regards,
Dsagar</p>Dayanand/matlabcentral/answers/contributors/5578780-dayanandtag:www.mathworks.de,2005:Question/1530972014-09-01T19:50:59Z2014-09-01T19:50:59ZGUI with two popup menus<p>Dear all,</p><p>I am new to GUI programming and I have tried to figure out for some time how to use two popup menus in a GUI.</p><p>Suppose popup menu 1 specifies a set of countries and popup menu 2 specifies a set of variables common to all countries. I would like to plot all possible country/variable pairs.</p><p>Below I show my code which does not work (potentially also because I do not appropriately pass the data between functions "popup_menu1_Callback" and "popup_menu2_Callback").</p><p>Any hints or suggestions would be great, many thanks!</p><p>Here is the example-code:</p><pre class="language-matlab">function example_gui
% SIMPLE_GUI2 Select a data set from the pop-up menu, then
% click one of the plot-type push buttons. Clicking the button
% plots the selected data in the axes.
</pre><pre class="language-matlab">% Create and then hide the GUI as it is being constructed.
f = figure('Visible','off','Position',[260,500,800,485]);
% Construct the components.
hplot = uicontrol('Style','pushbutton','String','Figure','Position',[615,420,100,25],'Callback',{@plot_Callback});
</pre><pre class="language-matlab">hpopup = uicontrol('Style','popupmenu','String',{'US','Japan'},'Position',[615,260,100,25],'Callback',{@popup_menu1_Callback});
htext = uicontrol('Style','text','String','Country','Position',[615,300,100,15]);
</pre><pre class="language-matlab">gpopup = uicontrol('Style','popupmenu','String',{'GDP','Trade Balance'},'Position',[615,180,100,25],'Callback',{@popup_menu2_Callback});
gtext = uicontrol('Style','text','String','Indicator','Position',[615,220,100,15]);
</pre><pre class="language-matlab">ha = axes('Units','pixels','Position',[50,60,500,385]);
align([hplot,gtext,htext,hpopup,gpopup],'Center','None');
</pre><pre class="language-matlab">% Change units to normalized so components resize automatically.
set([hplot,gtext,htext,hpopup,gpopup],'Units','normalized');
</pre><pre class="language-matlab">% Generate the data to plot.
vars=evalin('base','vars') % matrix with dimesnion 4x100
</pre><pre class="language-matlab">% Assign the GUI a name to appear in the window title.
set(f,'Name','Simple GUI')
% Move the GUI to the center of the screen.
movegui(f,'center')
% Make the GUI visible.
set(f,'Visible','on');
</pre><pre class="language-matlab">function popup_menu1_Callback(hObject,source,eventdata)
global data
% Determine the selected data set.
str = get(hObject, 'String');
val = get(hObject, 'Value');
</pre><pre class="language-matlab">% Set current data to the selected data set.
switch str{val};
case 'US'
data = vars(1:2,:)
case 'Japan'
data = vars(3:4,:)
end
end
</pre><pre class="language-matlab">function popup_menu2_Callback(hObject,source,eventdata)
global data
% Determine the selected data set.
str = get(hObject, 'String');
val = get(hObject, 'Value');
</pre><pre class="language-matlab">% Set current data to the selected data set.
switch str{val};
case 'GDP'
data = data(1,:)
case 'Trade Balance'
data = data(2,:)
end
end
</pre><pre class="language-matlab">function plot_Callback(source,eventdata)
</pre><pre class="language-matlab">plot(data);
</pre><pre class="language-matlab">end
</pre><pre class="language-matlab">end
</pre>kanimbla/matlabcentral/answers/contributors/2464004-kanimblatag:www.mathworks.de,2005:Question/1269742014-04-24T11:13:05Z2014-09-01T19:48:37Zhighlight a sliding window on image<p>Hi I have a sliding window on my image. If the pixels within a sliding window meet certain conditions then I need to higlight this window on the image so that it can be seen were the suspicious pixels are.</p><p>I have tried the following but the window is apprearing in the wrong position.
Can anyone help me please:</p><pre> if average>200
N2=8;
info2 = repmat(struct, ceil(size(Z, 1) / N2), ceil(size(Z, 2) / N2));
for row1 = 1:N2:size(Z, 1)%loop through each pixel in the 8x8 window
for col1 = 1:N2:size(Z, 2)
x = (row1 - 1) / N2 + 1;
y = (col1 - 1) / N2 + 1;</pre><pre> imgWindow2 = Z(row1:min(end,row1+N2-1), col1:min(end,col1+N2-1));
average2 = mean(imgWindow2(:));
window2(x,y).average=average2;</pre><pre> % if the intensity of the 8x8 window is greater than
% 210 then considered suspicious- calculate GLCM-
if average2>210</pre><pre> offsets0 = [0 1];%-1 1; -1 0; -1 -1];
glcms = graycomatrix(imgWindow2,'Offset',offsets0);
stats = graycoprops(glcms,'all'); </pre><pre> correlation=[stats.Correlation];
contrast=[stats.Contrast];
homogeneity=[stats.Homogeneity];
energy=[stats.Energy];</pre><pre> %if these conditions are met then this window
%contains an ROI
if (homogeneity > 0.9)
if (contrast<0.2)
if (energy>0.6)</pre><pre> % display('there is mass ')%use for testing </pre><pre> end
end
end</pre><pre> end % end if>210</pre><pre> end %end for col1
end %end for row1
end %end if average>200
end% end for col
end %end for row</pre><pre class="language-matlab">Z1 = insertShape(Z, 'rectangle', [x y 8 8]);
figure(2);
imshow(Z1);
</pre>Ciara/matlabcentral/answers/contributors/5102725-ciaratag:www.mathworks.de,2005:Question/1522292014-08-25T09:17:18Z2014-09-01T19:41:48ZOperations on Matrices over Finite field<p>Consider square matrices over finite field F(p). How to find out rank, determinant, inverse, eigenvalues over the field field F(p).</p><p>Need a code to do all above.</p>Sk. Sarif Hassan/matlabcentral/answers/contributors/5315921-sk-sarif-hassantag:www.mathworks.de,2005:Question/1530952014-09-01T19:31:02Z2014-09-01T19:33:37Zhow to uninstall earlier version of MATLAB on a Mac OS X?<p>Hi
I installed MATLAB R2013b on my Mac but updated to MATLAB R2014a recently. The two versions are in the same folder and the 2013 version blocks 8.8 GBs. Can I somehow remove the older version without loosing all my work?
cheers,
Michael</p>Michael/matlabcentral/answers/contributors/5441808-michaeltag:www.mathworks.de,2005:Question/1530922014-09-01T19:26:17Z2014-09-01T19:26:17ZWhy matchfeatures give wrong answer?<p>Hi guys,</p><p>I have two features vector A=[ 85.8038 57.4149; 144.1727 94.1888; 158.8450 189.1278]
and B=[ 87.1281 56.5832; 144.0943 94.7689; 158.4395 190.4297]</p><p>I run indexPairs = matchFeatures(A,B,'MatchThreshold',0.8) and have expected to achieve this result:</p><p>1 1
2 2
3 3
but I took this result:
1 2
3 3</p><p>If any body know a solution, please help me.</p>Afsaneh/matlabcentral/answers/contributors/2405278-afsanehtag:www.mathworks.de,2005:Question/1527492014-08-29T09:11:12Z2014-09-01T19:24:29ZFilter Design from Weighted coefficient.<p>Hello all,
I want to design a filter to get input signal. For that i have find the coefficent of an inverse of unknown filter and from these coeffiecents i want to design a filetr. But i don't have any clue how to design a filter from given coefficients in matlab.
One way that i know is if i have coefficient of filter, using that i will make a linear equation (i.e FIR equation) and using that i will make filter. But this procedure is too lengthy (i think).
So is there any inbuilt function available in matlab to design a filter using impulse response (coefficient).</p><p>Please help</p>Vijender/matlabcentral/answers/contributors/4547114-vijendertag:www.mathworks.de,2005:Question/1529552014-08-31T10:17:40Z2014-09-01T19:21:30ZGUI push button - create multiple plots<p>Dear all,</p><p>I am new to GUI-programming and my question is rather simple I hope. I am creating some plots using a push button. For the simple example-code below it works perfectly fine:</p><p>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p>% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes1);
cla;</p><p>vars = evalin('base','gui_A');</p><p>popup_sel_index = get(handles.popupmenu1, 'Value');
switch popup_sel_index</p><pre> case 1
plot(vars(:,:,1)');
case 2
plot(vars(:,:,2)');
case 3
plot(vars(:,:,3)');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</pre><p>What do I have to modify if I want to create a larger number of plots? I had the idea to write a loop like this:</p><p>for i=1:3</p><pre class="language-matlab">case i=plot(vars(:,:,i)')
</pre><p>end</p><p>However, it does not seem to work like this, please help!</p>kanimbla/matlabcentral/answers/contributors/2464004-kanimblatag:www.mathworks.de,2005:Question/1530652014-09-01T14:05:39Z2014-09-01T18:47:02ZHow to make a copy of a built-in function and get it to work?<p>I would like to change a built-in function of MATLAB, the histfit function. The problem is this function always give me the same number of points, which is 100, on the fitted curve. I want to change it so that I can specify the number of points on my own. I know I can't make any change on a built-in function, therefore I tried to make a copy of the histfit file, with different file name of course. But when I tried to use it it doesn't work saying</p><p>"Undefined function 'dfgetdistributions' for input arguments of type 'char'".</p><p>I know this must have to do with the built-in nature of histfit function. But is there still other ways to get around this? Seriously I wonder why MATLAB didn't give the user freedom to set the number of points in histfit on their own, it's really getting on my nerves.</p>Imam/matlabcentral/answers/contributors/5330169-imamtag:www.mathworks.de,2005:Question/1521772014-08-24T17:59:29Z2014-09-01T18:41:47ZHow to use narxnet for new set of data?<p>I trained a narxnet network with 4 inputs and 2 targets for system identification. The training performance (RMS) seems pretty good, but the problem is that I don't know how to use this net for new set of data.
According to the Matlab Help, I should use closed loop form (netc) for doing this:</p><p>netc = closeloop(net);
view(netc);
[Xs,Xi,Ai,Ts] = preparets(netc,X,{},T);
y = netc(Xs,Xi,Ai);</p><p>In this process, the target value (T) is required which doesn't make sense because target is not available for system identification.
How should I use this network for new set of input data while I don't have target values?</p>Sam136/matlabcentral/answers/contributors/5511365-sam136tag:www.mathworks.de,2005:Question/1530862014-09-01T17:23:23Z2014-09-01T20:52:36ZDifference between FFT and DFT spectrum! why ?!<p>Hi every body,
can some one help me to understand the reason of difference between the spectrum of the DFT(raw formulas) and FFT which I have implemented via the following code? I am investigating the harmonics up to 9 KHZ for a signal with 50 hz basic frequency and the differences appear mostly in ranges higher than 6 KHz.</p><p>I have run this code on a set of samples with 10004 samples which is attached to this post .(just import the variables to matlab and run the code below )</p><p>for DFT I have used the formulas in yhe below link : <a href = "http://www.mathworks.com/help/matlab/math/discrete-fourier-transform-dft.html">DFT formula</a></p><pre class="language-matlab">CODE:
</pre><pre class="language-matlab">%% reading in the samples
wave; %%% a 10004 samples signal with basic frequency of 50 Hz which means 10 complete period of the fundametal wave
</pre><pre class="language-matlab">%% Normal FFT
wavefft1 = fft(wave);
</pre><pre class="language-matlab">L=size(wave,1)-1; % removing the mirror side of spectrum
MagSpec1 = abs(wavefft1(1:1801))/(L/2); %% removing the mirror side of the spectrum
% and ranging the domain
</pre><pre class="language-matlab">%% DFT implementation
f = 49.985004498650405; %% f = 10/(time(10004)-time(1)) we have used 10 because these samples consist of 10 periods of the signal with 50 Hz frequency
Sampling_Fequency = 50000;
</pre><pre class="language-matlab">N = size (wave,1)
</pre><pre class="language-matlab">ll = 0;
for k = 0: f/10:180*f;
cplx_val =0;
for x = 1:N
Teta = ((2*pi*k*x)/Sampling_Fequency);
cplx_val = cplx_val+(wave(x,1)*complex(cos(Teta),(-1*sin(Teta))));
end
ll = ll+1;
</pre><pre> MagSpec2(ll,1) = (floor((abs(cplx_val)/(N/2))*10^6))/10^6; %% removing the mirror side of the spectrum
% and ranging the domain
end</pre><pre class="language-matlab">%% drawing the caomparison plot
</pre><pre class="language-matlab">set(0,'DefaultFigureVisible','on');
figure;
x1 = (0:1800)*5;
plot(x1,MagSpec1,'r-');hold on;
plot(x1,MagSpec2,'g-');
legend('FFT Normal','DFT');
</pre>Ali/matlabcentral/answers/contributors/5068635-alitag:www.mathworks.de,2005:Question/1530362014-09-01T08:25:08Z2014-09-01T18:34:24ZHelp needed in choosing population size<p>Hi,
I'm running a cfd geometry optimization case by using Matlab genetic algorithm(integer variables) with Ansys Fluent.I have 4 variables. Each iteration takes 4 minute to complete. There are a total of 3500 possible geometries.</p><p>I currently run the simulation at: Population Size 10, Number of Generations:25</p><p>Do you think is this enough for the population size?</p><p>Thanks.</p>Burak Pehlivan/matlabcentral/answers/contributors/2077572-burak-pehlivantag:www.mathworks.de,2005:Question/1530422014-09-01T09:15:13Z2014-09-01T18:12:16ZHow to make sure that matlab answer in command window is copied to text file in two distinct columns(in exactly the same way as a mirror image of the command window)?<p>A script is made to produce all permutations of vector x with vector y.
so each element of x is assigned to each element of y.
%-------
function rowpermutation_3 = rowpermutation3(x,y)
bla = 4
for k = 1:1e3
[ix, iy] = find(true(size(y, 1), size(x, 1)));
rowpermutation_3 = [x(ix(:), :), y(iy(:), :)];
rowpermutation_3 = [kron(x, ones(size(y,1),1)), repmat(y, [size(x, 1), 1])];
rowpermutation_3column1 = rowpermutation_3(:,1);
rowpermutation_3column2 = rowpermutation_3(:,2);
end
fid = fopen('fprintfrowpermutation3.txt','wt');
fprintf(fid, '%d %f\n',[rowpermutation_3column1,rowpermutation_3column2]);
fclose(fid)
end
%---------
The matlab commandow does produce the desired outcome,which is like this:
1 21
1 22
1 23
1 24
1 25
2 21
2 22
2 23
2 24
2 25
3 21
3 22
3 23
3 24
3 25
4 21
4 22
4 23
4 24
4 25
5 21
5 22
5 23
5 24
5 25
however my text file produces something different:
1 1.000000
1 1.000000
1 2.000000
2 2.000000
2 2.000000
3 3.000000
3 3.000000
3 4.000000
4 4.000000
4 4.000000
5 5.000000
5 5.000000
5 21.000000
22 23.000000
24 25.000000
21 22.000000
23 24.000000
25 21.000000
22 23.000000
24 25.000000
21 22.000000
23 24.000000
25 21.000000
22 23.000000
24 25.000000</p>Antoine van Hirtum/matlabcentral/answers/contributors/2091244-antoine-van-hirtumtag:www.mathworks.de,2005:Question/1530882014-09-01T17:56:46Z2014-09-01T17:58:04ZKalman Filter block that allows computing state transition matrix each time?<p>I would like to filter accelerometer data with a Kalman filter. One of the state variables will be velocity, and the other acceleration. Velocity will be a function of acceleration and elapsed time since the last iteration.</p><p>I do not want elapsed time to be a state variable. I would like to compute the state transition matrix on each iteration, but the Kalman Filter block in Simulink (dspadpt3) only has input ports for the measurement and the measurement matrix.</p><p>Is there another block, or way to use this one that I am not aware of, which will do what I want?</p>Sebastian/matlabcentral/answers/contributors/5441629-sebastiantag:www.mathworks.de,2005:Question/1529572014-08-31T10:34:41Z2014-09-01T17:53:34ZProblem creating axes with subplot<p>I have a little problem with subplot. Indeed, I try to create 8 axes using the commande subplot, I write this :</p><pre class="language-matlab">subplot(4,2,1,'position',[0.2 0.3 0.05 0.12]);
subplot(4,2,2,'position',[0.3 0.3 0.05 0.12]);
....
</pre><p>until the 8th axes.
But, when I run the programme, I get only 6 axes ! the lack is the first and the seconde. Why I have this problme ?</p>RABEHI/matlabcentral/answers/contributors/4775844-rabehitag:www.mathworks.de,2005:Question/1530672014-09-01T14:11:49Z2014-09-01T17:52:26ZSort Matrix Array and skip zeros.<p>I have an array as this:</p><pre> Array1 = [1 2 3 4 0 0;
1 2 3 0 0 0;
1 0 0 0 0 0;
1 2 0 0 0 0];</pre><p>Array1 is sorted and is fine as it is. But lets say I type in a mistake like this:</p><pre> Array2 = [2 1 3 4 0 0;
1 2 3 0 0 0;
1 0 0 0 0 0;
1 2 0 0 0 0];</pre><p>Now coulomb 1 in Array2 is not sorted and I would like to sort it. But when I try to sort it with the function sort(Array2(1,:)) the zeros (0) will be listed first. Its easy to understand why it does this because 0 is smaller then 1,2,3,4, etc. It will then look like:</p><pre> Array2 = [0 0 1 2 3 4;
1 2 3 0 0 0;
1 0 0 0 0 0;
1 2 0 0 0 0];</pre><p>But I would like the array to look like Array1:</p><pre> Array2 = [1 2 3 4 0 0;
1 2 3 0 0 0;
1 0 0 0 0 0;
1 2 0 0 0 0]</pre><p>How is this possible? Can I somehow sort an array and skip the zeros?</p><p>Your Sincerely.</p>Kalle/matlabcentral/answers/contributors/4054778-kalletag:www.mathworks.de,2005:Question/1529692014-08-31T14:26:20Z2014-09-01T17:47:45ZOptimizing nested for loop<p>I have the following for loop and it take quite a while to complete when I am sure it can be faster. It looks up an input value from the assigned dataset and extracts parameters from the struct based on the bin it falls into. Once these parameters have been selected for, the output is based on a calculation.</p><pre class="language-matlab">nrows = length(inpdata);
ncols = 2:2:12;
</pre><pre class="language-matlab">for j = ncols;
for i = 1:nrows;
if j == 2
height = 'height10m';
elseif j == 4
height = 'height20m';
elseif j == 6
height = 'height40m';
elseif j == 8
height = 'height80m';
elseif j == 10
height = 'height120m';
elseif j == 12
height = 'height200m';
end
</pre><pre> if inpdata(i,j) > 0
param = strcat('params',num2str(length(bin(bin < inpdata(i,j)))));
gusts(i,j) = inpdata(i,j) + (inpdata2.(height).(param)(1,3)*(inpdata(i,j)^(1 + inpdata2.(height).(param)(1,1))));
elseif inpdata(i,2) == 0
param = 'params1';
gusts(i,j) = inpdata(i,j) + (inpdata2.(height).(param)(1,3)*(inpdata(i,j)^(1 + inpdata2.(height).(param)(1,1))));
end
end
end</pre><p>I am not too sure how to optimize this for more efficiency but does anyone have any suggestions? The profiler shows that it is the strcat and num2str functions that are the main culprits but I am not sure how to optimize them as I need them in the loop.</p>Masao Ashtine/matlabcentral/answers/contributors/4739967-masao-ashtinetag:www.mathworks.de,2005:Question/1530472014-09-01T10:59:52Z2014-09-01T17:43:44Zmaximum variable size allowed by the program is exceeded?<p>PLz help me</p><p>This is the code</p><pre> alps=17; %slope angle
dz=200; %depth of water table from the suface
dlz=400; % toltal depth of slope
fi=25; %friction angle
C=0.4; %4 kpa=0.4 N/cm^2
gsat=0.21; %21 kN/m^3
gw=0.098; %9.81 Kn/m^3
Dzero=4; %0.0004m^2/s
ksat=1e-3; %e-5 m/s
iz=2e-4; %iz=7.2 mm/h= 2e-4 cm/s
deltat=10; %time step
deltaz=0.8; %space step
T=12*60*60; %time duration of rainfall= 12h to seconds
e=(deltat/deltaz^2)*Dzero*cos(17*pi/180)*cos(17*pi/180);
n=500; %time step, based on T</pre><pre> %Setup sparse matrix</pre><pre> b= sparse(1:n,1:n,-116.314,n,n); % element b... 1...n
c= sparse(1:n-1,2:n,e,n,n); % element c...
a= sparse(2:n,1:n-1,-e,n,n); % element a... 2...n-1</pre><pre> c(1)=114.314; a(1)=0; a(n)=114.314; %Boundary condition
A= a+b+c;</pre><pre> l=e*ones(1:n); m=112.314*ones(1:n); u=e*ones(1:n);</pre><p>and
This is the error below, please tell me why this error appears and how to solve.
My system is 64 bit and 6gb ram and processor speed is 2.5 Ghz
Error using ones
Maximum variable size allowed by the program is exceeded.</p><pre> Error in hillslopesparse (line 30)
l=e*ones(1:n); m=112.314*ones(1:n); u=e*ones(1:n);</pre>advaita vedanta/matlabcentral/answers/contributors/2227782-advaita-vedantatag:www.mathworks.de,2005:Question/1530832014-09-01T16:48:44Z2014-09-01T17:38:57ZGenerate size-adjustable uniform grid for spatial calibration<p>Hi, everyone,</p><p>I took a tiff image of a dot array on a piece of white paper, the resolution of the camera is 1280 x 800.</p><p>After I use imread to read in and use imshow to show the tiff image in Matlab, I am now trying to generate a 2-D uniform grid and add it to the image.</p><p>In this way, I will have a better understand of the relative pixel location for each dot on the paper. Then I can calibrate the relationship between the pixel location (i,j)and spatial location(x,y).</p><p>Besides, if possible, I need to make one unit grid containing 6-8 pixels, and make the grid size adjustable in case I need to adjust the size for better calibration.</p><p>Now I am stuck in generating this size-adjustable 2-D uniform grid.</p><p>Can anyone help me please?</p><p>Thank you for your kind help</p>zy/matlabcentral/answers/contributors/5333595-zytag:www.mathworks.de,2005:Question/1530442014-09-01T09:46:59Z2014-09-01T17:31:18Zwhy the mean value of a unit pulse is zero<p>Mean value of a unit pulse is zero ?</p>MANJUNATH/matlabcentral/answers/contributors/3243248-manjunathtag:www.mathworks.de,2005:Question/1530872014-09-01T17:31:17Z2014-09-01T17:31:17Zn-D lookup in simscape<p>Hi all,
is there any way to use a n-D lookup table in simscape. tablelookup only supports 2d tables..</p><p>Thanks
Bhaskar</p>Bhaskar/matlabcentral/answers/contributors/4840481-bhaskartag:www.mathworks.de,2005:Question/1529202014-08-30T19:41:26Z2014-09-01T17:19:31ZHow to store the coordinates of a bounding box in a video?<p>Hello. I am working on a project where i use a camera to detect moving objects. Now what i want to do is to create a code in order to save the x and y coordinates of a (moving) bounding box (in all the frames of my video that is visible). I tried the code below but it saves only the last x and y k-times, where k is the number of frames of my video.</p><pre> ....
while ~isDone(hVidReader) % Stop when end of file is reached
frame = step(hVidReader); % Read input video frame</pre><pre> grayFrame = rgb2gray(frame);</pre><pre> %The optical flow vectors are stored as complex numbers.
ofVectors = step(hOpticalFlow1, grayFrame); % Estimate optical flow
%Compute their magnitude squared which will later be used for thresholding.
y1 = ofVectors .* conj(ofVectors);
% Compute the velocity threshold from the matrix of complex velocities.
vel_th = 0.5 * step(hMean2, step(hMean1, y1));
% Threshold the image and then filter it to remove speckle noise.
segmentedObjects = step(hMedianFilt, y1 >= vel_th);
% Thin-out the parts of the road and fill holes in the blobs.
segmentedObjects = step(hclose, step(herode, segmentedObjects));
% Estimatethe area and bounding box of the blobs.
[area, bbox] = step(hblob, segmentedObjects);
% Select boxes inside ROI.
Idx = (bbox(:,1) > lineRow1 & bbox(:,1) < lineRow2)&(bbox(:,2) > lineColumn1 & bbox(:,2) <
lineColumn2);
% Based on blob sizes, filter out objects which can not be cars.
% When the ratio between the area of the blob and the area of the
% bounding box is above 0.4 (40%), classify it as a car.
ratio = zeros(length(Idx), 1);
ratio(Idx) = single(area(Idx,1))./single(bbox(Idx,3).*bbox(Idx,4));
ratiob = ratio > 0.4;
count = int32(sum(ratiob)); % Number of cars
bbox(~ratiob, :) = int32(-1);
% Draw bounding boxes around the tracked cars.
y2 = step(hshapeins1, frame, bbox);
% Display the number of cars tracked and white lines showing the ROI.
y2(22:25,250:1097,:) = 1; % The top white line.
y2(230:233,250:1097,:) = 1; % The bottom white line.
y2(25:230,247:250,:) = 1; % The left white line.
y2(25:230,1097:1100,:) = 1; % The right white line.
y2(1:15,1:30,:) = 0; % Background for displaying count
result = step(htextins, y2, count);</pre><pre> for jj = 1 : k
if bbox ~ [];
if bbox(1,1)>0
xbbox(jj) = bbox(1,1);
ybbox(jj) = bbox(1,2);
zz(:,:,jj) = [xcentroid,ycentroid];</pre><pre> else
xbbox(jj) = 0;
ybbox(jj) =0;
zz(:,:,jj) = 0;
end
end
end</pre><pre> % Generate coordinates for plotting motion vectors.
if firstTime
[R , C] = size(ofVectors); % Height and width in pixels
RV = borderOffset:decimFactorRow:(R-borderOffset);
CV = borderOffset:decimFactorCol:(C-borderOffset);
[Y ,X] = meshgrid(CV,RV);
firstTime = false;</pre><pre> end</pre><pre> % Calculate and draw the motion vectors.
tmp = ofVectors(RV,CV) .* motionVecGain;
lines = [Y(:), X(:), Y(:) + real(tmp(:)), X(:) + imag(tmp(:))];
motionVectors = step(hshapeins2, frame, lines);
% Display the results</pre><pre> step(hVideo4, result); % Video with bounding boxes</pre><pre> end
release(hVidReader);</pre><p>The lines i was talking about are:
for jj = 1 : k
if bbox ~ [];
if bbox(1,1)>0
xbbox(jj) = bbox(1,1);
ybbox(jj) = bbox(1,2);
zz(:,:,jj) = [xcentroid,ycentroid];</p><pre> else
xbbox(jj) = 0;
ybbox(jj) =0;
zz(:,:,jj) = 0;
end
end
end</pre><p>I also tried other things but the outcome was about the same. I don't know if i gave you adequate iinformation, so please ask me anything you want. Thank you all in advance.</p>Nikolaos/matlabcentral/answers/contributors/5367525-nikolaostag:www.mathworks.de,2005:Question/1529312014-08-30T21:30:25Z2014-09-01T17:17:35ZHow to translate the following code from Mathematica to Matlab?<p>I need to construct a matrix similar to the following:</p><p>l = 2; m = 4;
Table[(2 x - y*l)/m, {x, 0, 5}, {y, 0, 5}] // MatrixForm</p><img src = "/matlabcentral/answers/uploaded_files/17590/Untitled.jpg"><p>How can I do that in Matlab?</p>Tigo/matlabcentral/answers/contributors/5560534-tigotag:www.mathworks.de,2005:Question/1530842014-09-01T16:55:25Z2014-09-01T16:55:25ZHow to extract the neighborhood node value from this graph ? <img src = "/matlabcentral/answers/uploaded_files/17654/Capture11.jpg"><p>I'm plotting this graph by using this command "voronoi". And now i want to extract the value of each "node" in "cluster".</p>Arul prasath/matlabcentral/answers/contributors/4647176-arul-prasathtag:www.mathworks.de,2005:Question/1530662014-09-01T14:05:57Z2014-09-01T16:48:24ZHow do I make sure that all the dependencies of shared libraries are included in a compiler build?<p>I'm trying to make an executable of my MATLAB app which uses some shared libraries (camera drivers). The way I deal with handling libraries, I created a prototype *.m file and then use it when loading a library (all using the loadlibrary function).</p><p>The code runs fine from MATLAB but as soon as I build it using the MATLAB Compiler it throws an error:</p><pre class="language-matlab">Error using loadlibrary (line 419)
The specified module could not be found.
</pre><p>All that even though I've specified that the additional include and header folders in the build preferences.</p><p>I suspect that it has to do with the fact that somehow not all of the files in the shared library folders are included in the build.</p><p>Does anyone know the proper way to do shared libraries with MATLAB and its compiler?</p>Kuba/matlabcentral/answers/contributors/3757605-kuba