http://www.mathworks.de/matlabcentral/answers/questions.atomMATLAB Answers — New Questions20140916T04:52:42Ztag:www.mathworks.de,2005:Question/15498120140916T04:52:42Z20140916T04:52:42Z How to find common time between two time series<p>How to find common time between two time series</p>Chris Martin/matlabcentral/answers/contributors/3732386chrismartintag:www.mathworks.de,2005:Question/15281820140829T22:47:44Z20140916T04:49:10ZHow to covert a vector of lower triangular matrix factors back to the original matrix?<p>Hi guys</p><p>Could you pleas offer me some help with how to covert a vector to a matrix?</p><p>for example, the vector I have is [ 1 2 2 3 5 3 4 9 8 4]</p><p>And the desirable result is:</p><p>1 2 3 4</p><p>2 2 5 9</p><p>3 5 3 8</p><p>4 9 8 4</p><p>The vector I have is actually the factors of the lower triangular matrix of a covariance matrix,
right now I want to convert it back to the original covariance matrix. The actual length of the vector I have is like 70,000+ ...</p><p>Thx a lot!!</p>Jason/matlabcentral/answers/contributors/5449653jasontag:www.mathworks.de,2005:Question/14093420140708T14:39:07Z20140916T04:46:48ZDisplay String Arrays in a Listbox<p>Hey Guys,</p><p>I am a MatlabNewbie and I have a smale Problem, which I can not solve.</p><p>I have 9 String Arrays (all different size) and I want to display them all in one Listbox.
The Arrays are saved in an .matfile. So I need to Load() them and then displazy them all in my Listbox. I would be really tankful if anyone of u could help me. ( and ignore my eng.Skills)</p><p>And can u pls answer me the general Question: How can I add things to my Listbox without killing the content, which is allready added.</p><p>PS: the command 'append' means the 'save' command does not overwrite an existing matfile. It just adds new content. Need sth like this for my listbox.</p>Max Müller/matlabcentral/answers/contributors/5451121maxmullertag:www.mathworks.de,2005:Question/15496720140916T02:33:45Z20140916T04:45:11ZSolving multiple nonlinear equations<p>Hi,</p><p>I have five nonlinear equations, and I am trying to solve for five unknowns. No answers were found when I tried to use fsolve in MatLab and Findroot in Mathematica. However, when I tried to manipulate the equations in Mathematica, those five lines (equations) do seem to intercept at a certain point. When I used those values as my initial guess for fsolve or findroot, there is no valid answers...
Any idea?</p><p>Also, I do know what value ranges these unknowns need to be, but how do you have fsolve search in a range?</p><p>Thanks for the help!</p>Fan/matlabcentral/answers/contributors/5270619fantag:www.mathworks.de,2005:Question/15498020140916T04:30:59Z20140916T04:39:13Zhow to fix constant iteration in neural networks<p>when i am trying to train my neural network using levenberg marquardt algorithm it shows different iteration at each times how do i fix my neural network with constant iteration period</p>Thirunavukkarasu/matlabcentral/answers/contributors/5497970thirunavukkarasutag:www.mathworks.de,2005:Question/15491920140915T17:59:53Z20140916T04:37:42ZHow to represent the value of X and Y Pixels in array of Two Dimensions using Matlab<p>Hi , Suppose if this is my image</p><img src = "/matlabcentral/answers/uploaded_files/18182/untitled.jpg"><p>I need to find the x, y coordinates of white pixels in image. I am getting the value of x and y coordinates separately one after the other, i want to represent it in 2 dimensional array matrix like [x,y] ,how can i represent it in 2 D matrix?</p><p>Then i need to calculate the farthest distance in that box ? how to solve this?</p>Lakshya/matlabcentral/answers/contributors/5534534lakshyatag:www.mathworks.de,2005:Question/15491020140915T17:05:12Z20140916T04:35:09Zi am trying to create a gui which includes one table (containing editable columns ) and a push button. i want to get the data which a user enters in the table to a variable when the push button is clicked. how can i do this ? <p>data</p>rashmi am/matlabcentral/answers/contributors/5511857rashmiamtag:www.mathworks.de,2005:Question/15496020140915T23:47:46Z20140916T04:30:27Zi am trying to create a gui which includes one table (containing editable columns ) and a push button. i want to get the data which a user enters in the table to a variable when the push button is clicked. how can i do this ?<p>data table</p>rashmi am/matlabcentral/answers/contributors/5511857rashmiamtag:www.mathworks.de,2005:Question/15497620140916T04:12:24Z20140916T04:26:38ZTrouble using while loops<p>Give the following function</p><p>f(x)= x^3 (5x)^2 +2^(x)  10000x</p><p>Use a while loop to compute f(x) and then create a plot for 0<x<20.</p><p>This is what I have so far, I know I have to define x but I don't know what to set x= to since it did not specify.</p><p>f(x)=x^3 (5*x)^2 +2^(x) 10000*x;</p><p>while 0<x<20</p><p>end</p>Leora/matlabcentral/answers/contributors/3633436leoratag:www.mathworks.de,2005:Question/15484120140915T05:20:20Z20140916T04:18:44ZHow can I solve this error : fminunc stopped because it exceeded the function evaluation limit, options. MaxFunEvals = 100 (the default value).<p>I am writing aMatlab code whish should use fminunc during it. After runing my code, this error appear, how can solve it?</p>sherrysherry/matlabcentral/answers/contributors/4847804sherrysherrytag:www.mathworks.de,2005:Question/15492120140915T18:29:49Z20140916T04:16:06Zcan someone help me to plot in audio plocessing?<p>hi fiends, i have a problem with my program, i have to process an audio and make a different transformations for this audio, the fist transformatios is a delay in the time that the audio begins, but i have a doubt because when i plot the signal, the numbers dont coincide with the number i have for the seconds that i have to delay the signal. can somebody help me? please. this is my code, i have try in two different ways and bouth of them give me the same result.</p><p><b>i 've try this way</b> :</p><pre class="languagematlab">[x,fs]=wavread('anita.wav');
cor=input('seconds you wanna delay: ');
cor=cor*fs;
otra=zeros(cor,2);
onda=vertcat(otra,x);
wavwrite(onda,fs,'delay.wav');
</pre><pre class="languagematlab">[y,Fs]=wavread('delay.wav');
sound(x,Fs);
sound(y,Fs);
</pre><pre class="languagematlab">subplot(2,1,1);
plot(x);
subplot(2,1,2)
</pre><pre class="languagematlab">plot (y);
</pre><p><b>and this:</b></p><pre class="languagematlab">[x,fs]=wavread('anita.wav');
cor=10;
cor=cor*fs;
otra=zeros(cor,2);
onda=vertcat(otra,x);
wavwrite(onda,fs,'delay.wav');
[y,Fs]=wavread('delay.wav');
%sound(x,Fs);
%sound(y,Fs);
j=length(y);
f=y((endj+1):1:end)
subplot(2,1,1);
plot(x)
subplot(2,1,2)
plot (f)
</pre><p>the other transformation is an expansion an a compression with the audio, the faster an the lower you want to make the audio, but again i think that the plots are wrong, because the numbers don't coincide with the time. can someone help me to make them right? this is the code:</p><p><b>compression</b></p><pre> [x,Fs]=wavread('anita.wav');
t=input('seconds to compress:');
rut=Fs*t;
f=z(1:rut);
plot(x);
plot(f);</pre><p><b>expansion</b></p><pre> [x,Fs]=wavread('anita.wav');
t=input('seconds to expand:');
rut=Fs/t;
f=z(1:rut);
plot(x);
plot(f);</pre>alejandra/matlabcentral/answers/contributors/5544405alejandratag:www.mathworks.de,2005:Question/15497920140916T04:15:12Z20140916T04:15:12ZHow can I implement saturable reactor?<p>I want to get a simulink block of saturable reactor, not saturable transformer.</p><p>If anyone has that block or code, Please send it or contact me.</p><p>thanks/</p>jh dd/matlabcentral/answers/contributors/5647245jhddtag:www.mathworks.de,2005:Question/15497820140916T04:14:25Z20140916T04:14:25Zas an M.s student of structural engineering who is trying to present my thesis, would be most obliged if you could advise me how i may detect discontinuity of a signal by using curvelet transform in the meantime would appreciate if you could let me k<p>for example signal is :
1<t<2 signal=t^2 +1,,,,,,
1<t<2 signal=t^34</p>mohamad yousefbeik/matlabcentral/answers/contributors/5565390mohamadyousefbeiktag:www.mathworks.de,2005:Question/15497320140916T03:55:43Z20140916T04:11:43ZMatrices dimension problem please help<p>I have an issue with a very basic code using matrices. I had to define 3 matrices and do a few operations. I got them all correct except for the last one. It says the dimensions don't match but that is what the question is telling me to do. Any help would be appreciated.</p><pre class="languagematlab">A=[1,2,3;4,5,6;7,8,9]; %Defining matrices A,B and C
B=[2,8,2;1,1,1;7,0,2];
C=[2;0;1];
A+B
A.*B transpose(C)*B
inv(A)*(C).^1
B+(C).^2
</pre>Leora/matlabcentral/answers/contributors/3633436leoratag:www.mathworks.de,2005:Question/15497220140916T03:21:10Z20140916T03:55:18ZSimple matlab code issue<p>I have an issue with a very basic code using matrices. I had to define 3 matrices and do a few operations. I got them all correct except for the last one. It says the dimensions don't match but that is what the question is telling me to do. Any help would be appreciated.</p><p>A=[1,2,3;4,5,6;7,8,9]; %Defining matrices A,B and C
B=[2,8,2;1,1,1;7,0,2];
C=[2;0;1];
A+B
A.*B
transpose(C)*B
inv(A)*(C).^1
B+(C).^2</p><p>The last one is incorrect and the question asks me to do B+C^2</p>Leora/matlabcentral/answers/contributors/3633436leoratag:www.mathworks.de,2005:Question/15492920140915T19:30:31Z20140916T03:45:23Zcan any one tell how this break function works in this loop??<p>can any one tell me how the break functions if there are two if conditions in a for loop ...</p><pre class="languagematlab">if true
% code
end
locs_Qwave=[ 100 150 90 1175 1 50]';
locs_Rwave=[116 170]';
q=0
k=1
for j=k:size(locs_Rwave)
</pre><pre> for i=1:numel(locs_Qwave)</pre><pre> if (i== numel(locs_Qwave))
q=[q locs_Qwave(i)];</pre><pre> break;
end</pre><pre> if( locs_Qwave(i)>locs_Rwave(j))
q=[q locs_Qwave(i1)];
break;</pre><pre> end</pre><pre> end</pre><p>end</p>Abhishek sadasivan/matlabcentral/answers/contributors/2454716abhisheksadasivantag:www.mathworks.de,2005:Question/15491620140915T17:44:24Z20140916T03:39:18Z [SimMechanics Gen 2] Translation in global world frame<p>Hello,</p><p>we want to translate a rigid in respect to the world frame with the rigid transform block.
But since our base frame is rotated, we always translate in respect to the base frame and not the world frame.
Is it possible to translate our object in respect to the world frame, even though our base frame is rotated?</p><p>Thanks!</p>H/matlabcentral/answers/contributors/5573632htag:www.mathworks.de,2005:Question/218320110228T13:27:00Z20140916T03:37:59ZExtracting 2D image from 3D volume data set<p>Hello,</p>
<pre class="languagematlab">I have 3D data set (M x N x P), and i need to extract irregular (not parallel) 2D planes (crosssections). And show it as an image. Maybe somebody tried this before?
</pre>Andrius/matlabcentral/answers/contributors/1845373andriustag:www.mathworks.de,2005:Question/15408820140909T03:34:28Z20140916T03:30:54ZProblem with mex setup for FORTRAN<p>I got a error message with</p><pre class="languagematlab">mex setup FORTRAN.
</pre><p>Error using mex
No supported compiler or SDK was found. For options, visit <a href = "http://www.mathworks.com/support/compilers/R2014a/win64">http://www.mathworks.com/support/compilers/R2014a/win64</a>.</p><p>I am using MATLAB R2014a in Windows 64 bit.
I have Intel Visual Fortran Composer XE 2013 in Microsoft Visual Studio 2010 Shell and in Microsoft Visual Studio 2008 Professional Edition.</p><p>I tried with C language and do not have any problem.</p><p>Thanks.
Durga</p>Durga Lal Shrestha/matlabcentral/answers/contributors/283520durgalalshresthatag:www.mathworks.de,2005:Question/15487020140915T11:43:04Z20140916T03:28:25ZHow can I solve fit inverse trigonometric function to a set of data points?<p>Hi all,
I have to find the equation using magic formula to model a friction damper to be used in ADAMS software for dynamic simulation.</p><p>Y=D*sin[C*arctan{(1E)*B*X+E*arctan(B*X)}]</p><p>I am trying to solve the Magic Formula (tire simulation) for the variables B, C, D and E in the above equation.I have the damper characteristic curve from which I extracted data points. Now I have to fit a curve equation that would fit the behavior it.</p><img src = "/matlabcentral/answers/uploaded_files/18164/Untitled.jpg"><p>If it is possible to fit any other equation (polynomial or trigonometric), would be helpful.
Can I fit a spline and extract the equation in this case?</p>Prathap/matlabcentral/answers/contributors/4787149prathaptag:www.mathworks.de,2005:Question/15494720140915T21:55:33Z20140916T03:16:31ZUsing MATLAB to create a random N,1 array of zeros and ones.<p>The question is that there have been 91 major plane crashes in 10 years, so i am trying to create a matrix of 3652 days,I am using a for loop to fill the matrix such that</p><pre class="languagematlab">N=3652;
X=zeros(1,N)
for i=1:N;
i=rand()
if i<=91/3652;
X(i)=1;
else
X(i)=0;
</pre><p>(Obviously wrong)</p><p>and then i need to find the maximum number of plane crashes in 8 days, so i am trying to find the probability of the recent plane disasters.</p><p>My code for finding this is</p><pre class="languagematlab">y = zeros(n7,1);
for i=1:n7
y(i) = sum(x(i:i+7));
end
</pre><p>Your help is much appreciated
note probability of a crash = 91/3652</p>Nick Kyle/matlabcentral/answers/contributors/5646007nickkyletag:www.mathworks.de,2005:Question/15463120140913T13:15:29Z20140916T03:15:52Zparallel execution of system command<p>Is there a way to execute a system command (ie calling up a dos executable/bang operator) parallely.
Within a for loop I'm calling up an exe file via system(). However it runs for few mins due to the interaction of internet. In windows its possible to open multiple sessions of dos and run executables.
How can I get matlab to open multiple parallel dos sessions.</p>Rashmil Dahanayake/matlabcentral/answers/contributors/4311650rashmildahanayaketag:www.mathworks.de,2005:Question/14079920140707T22:42:55Z20140916T03:10:40Z3way Repeated Measures ANOVA pairwise comparisons using multcompare<p>I'm expanding on a helpful question/answer I found here: <a href = "http://www.mathworks.com/matlabcentral/answers/124353doesfitrmranovasupportwithinsubjectmodelswithoutbetweensubjectfactors">http://www.mathworks.com/matlabcentral/answers/124353doesfitrmranovasupportwithinsubjectmodelswithoutbetweensubjectfactors</a></p><p>I have run a 3way repeated measures ANOVA with 3 within subject factors. I want to make the pairwise comparisons for the 2 and 3way interactions; I can run these for the 2way interactions using the method RepeatedMeasuresModel/multcompare but I cannot figure out how to do it for the 3way interaction. Here is my example:</p><pre class="languagematlab">% generate random data for the example
alpha_power = randn(24,8);
</pre><pre class="languagematlab">% Create a table storing the respones
varNames = {'Y1','Y2','Y3','Y4','Y5','Y6','Y7','Y8'};
t = array2table(alpha_power,'VariableNames',varNames);
</pre><pre class="languagematlab">% Create a table reflecting the within subject factors 'TestCond', 'Attention', and 'TMS' and their levels
factorNames = {'TestCond','Attention','TMS'};
within = table({'M';'M';'M';'M';'N';'N';'N';'N'},{'A';'A';'V';'V';'A';'A';'V';'V'},{'T';'S';'T';'S';'T';'S';'T';'S'},'VariableNames',factorNames);
</pre><pre class="languagematlab">% fit the repeated measures model
rm = fitrm(t,'Y1Y8~1','WithinDesign',within);
</pre><pre class="languagematlab">% run my repeated measures anova here
[ranovatbl] = ranova(rm, 'WithinModel','TestCond*Attention*TMS');
</pre><pre class="languagematlab">% make pairwise comparisons for the twoway interactions
%
% see: help RepeatedMeasuresModel/multcompare
multcompare(rm,'TestCond','By','Attention')
multcompare(rm,'TestCond','By','TMS')
multcompare(rm,'Attention','By','TMS')
</pre><pre class="languagematlab">% but how can I make pairwise comparisons for the 3way interaction?
%
% this does not work (it ignores the 'Attention' factor)
multcompare(rm,'TestCond','By','Attention','By','TMS')
</pre><p>I found this old discussion, but it was not helpful (it refers to the standalone multcompare function): <a href = "http://www.mathworks.com/matlabcentral/answers/2141howtoobtainpvaluesforallpairwisecomparisonsfromthemulticomparefunction">http://www.mathworks.com/matlabcentral/answers/2141howtoobtainpvaluesforallpairwisecomparisonsfromthemulticomparefunction</a></p><p>Is it possible to test the pairwise comparisons in the 3way interaction?</p>Matt Mollison/matlabcentral/answers/contributors/2250119mattmollisontag:www.mathworks.de,2005:Question/15496620140916T02:21:49Z20140916T03:18:33ZProblem using integral in a nonlinear system<p>Hello,
I'm trying to solve a 4x4 nonlinear system of equations (using fsolve and lsqnonlin). Two of these equations have integrals, so at first use "int" in them, however, they do not have explicit solutions. So after try to solve using "integral" instead of "int", but not work either.
I think the problem is with the integrals, because attempts to calculate it separately I get no results. The integral is:</p><pre class="languagematlab">integral((18000000*(1740853180245066011576893440000000*lambda10 + 518109338505567084173161632431603712*exp(t/10)  51810602260580064227258209148465058700*t^2*exp(t/10)  263671875*7452311944676252099^(1/2)*exp(t/20)*(12952650565145016056814552287116264675*t^2*exp(t/10)  129527334626391771043290408107900928*exp(t/10)  435213295061266502894223360000000*lambda10)^(1/2) + 5273437500*7452311944676252099^(1/2)*t*exp(t/20)*(12952650565145016056814552287116264675*t^2*exp(t/10)  129527334626391771043290408107900928*exp(t/10)  435213295061266502894223360000000*lambda10)^(1/2)))/(435213295061266502894223360000000*lambda10 + 129527334626391771043290408107900928*exp(t/10)  12952650565145016056814552287116264675*t^2*exp(t/10)),tau,T1)
</pre><p>where even after giving values to the constants that I want to find (lambda10, tau, T1), gives me the following error:
"Error using integralCalc / finalInputChecks (line 515)
Output of the function must be the same size as the input. If FUN is an arrayvalued integrand, Set the 'ArrayValued' option
to true.</p><p>Error in integralCalc / iterateScalarValued (line 315)
finalInputChecks (x, fx);</p><p>Error in integralCalc / vadapt (line 133)
[q, errbnd] = iterateScalarValued (u, TInterval, pathlen);</p><p>Error in integralCalc (line 76)
[q, errbnd] = vadapt (@ AtoBInvTransform, interval);</p><p>Error in integral (line 89)
IntegralCalc Q = (fun, a, b, opstruct); "</p><p>Please help!!</p>Jurgen/matlabcentral/answers/contributors/5646796jurgentag:www.mathworks.de,2005:Question/15485120140915T07:14:59Z20140916T03:07:04ZHow can i know the edge weight of each region in an image.?<p>How can i know the edge weight of each region in an image.?</p>moon sun/matlabcentral/answers/contributors/5642314moonsuntag:www.mathworks.de,2005:Question/15470720140914T06:36:09Z20140916T03:05:22Zset parameters of nlinfit function<p>Hi</p><p>I’m beginner in MATLAB. I have some experimental points and I used nlinfit function to solve my problem and find the best LS curve fitting result. When I use the nlinfit, it pass MSE= 1.5873e+07 and the result is not very good. I attached my data, please check output of nlinfit function to see the output.</p><p>Note: I want to find the best curve fitting based on spherical model, soI use:
fun = @(p,X) p(1)*(1.5*X/p(2)0.5*(X/p(2)).^3);</p><p>How I should set function’s arguments to reach the best results?
Please help me to solve my problem.</p><p>Best regards</p>Mani Ahmadian/matlabcentral/answers/contributors/4207149maniahmadiantag:www.mathworks.de,2005:Question/15487520140915T12:33:16Z20140916T02:59:17ZLoading Csv files and plotting them as 3D graphs<p>Have a bunch of cvs files, and need to load them into matlab. Eventually plotting them as 3D maps.</p><p>cvsread is returning an error at the momoment.</p><p>Thanks Andrew</p>Andrew/matlabcentral/answers/contributors/5642285andrewtag:www.mathworks.de,2005:Question/15497020140916T02:56:09Z20140916T02:56:09Zlimit of the number of avtivation times and how check current number<p>近く一時的なマシンの移設を考えています。
そのため、「アクティベーションの回数制限」と「現在のアクティベーション回数を確認する方法」を教えて頂けないでしょうか？</p>Keiichi/matlabcentral/answers/contributors/4950048keiichitag:www.mathworks.de,2005:Question/15493420140915T19:44:08Z20140916T02:51:42ZHow to choose one value for each row and column in a matrix so that the sum of values in the matrix is minimized<p>I am trying to develop an algorithim to automate a site selection process. Each column of the matrix represents a site of interest and each row represents a monitor collecting data within an acceptable buffer distance from each site and the numeric value represents the distance from the monitor to the site of interest. Since I want to obtain the largest data set possible I first want to maximize the number of sites with monitoring data and then minimize the total distance, or the sum of the selected numbers. Essentially only one value can be selected for each row and column in the matrix. The algorithim should select the starred values in the examples below.</p><pre class="languagematlab">d1 =
</pre><pre> 0.00000 22.61630 12.02885 0.00000 *14.99793*
0.00000 0.00000 0.00000 0.00000 0.00000
0.00000 0.00000 0.00000 *7.40015* 0.00000
0.00000 0.00000 0.00000 0.00000 0.00000
0.00000 0.00000 *28.56141* 10.98434 0.00000</pre><p>d1 =</p><pre> 0.00000 22.61630 14.9980 *12.3234* 0.00000
*23.0000* 0.00000 0.00000 21 0.00000
0.00000 0.00000 0.00000 0.00000 *7.40032*
0.00000 0.00000 0.00000 0.00000 0.00000
0.00000 0.00000 0.00000 0.00000 10.98434 </pre>Rachel/matlabcentral/answers/contributors/3021017racheltag:www.mathworks.de,2005:Question/12435320140403T15:16:56Z20140916T02:49:22ZDoes fitrm & ranova support within subject models without between subject factors<p>I am trying to use fitrm and ranova (Matlab2014a) to run a repeated measures anova on a 2x2 within subjects design. I currently have 4 variables representing the responses for all subjects in each cell of the 2x2 design.</p><p>I do not wish to include a between subject factor but rmfit seems to require at least one.</p><p>The code I am using is as follows.</p><p>alpha_power = randn(24,4); % This is my data but lets generate it for now
t = table(alpha_power(:,1),alpha_power(:,2), alpha_power(:,3), alpha_power(:,4),'VariableNames',{'Y1','Y2','Y3','Y4'}); % Create a table storing the respones</p><p>within = table({'A';'A';'V';'V'},{'T';'S';'T';'S'},'VariableNames',{'Attention','TMS'}); % Create a table reflecting the within subject factors 'Attention' and 'TMS' and their levels.</p><p>rm = fitrm(t,'Y1Y4','WithinDesign',within); % Here the code breaks.</p><p>fitrm seems to require terms in the model specification which reflect the predictor variables (e.g. 'Y1Y4~Gender'), but these are automatically specified as between subject factors, I do not have between subject factors.</p><p>Is it possible to specify terms as within subject factors?</p>Jim/matlabcentral/answers/contributors/3515805jimtag:www.mathworks.de,2005:Question/15496920140916T02:43:46Z20140916T02:58:48ZHow to search neighbor <p>Hi for example I built a matrix like:</p><p>M=</p><pre> 150 12 2 15 160
12 36 150 150 18
8 150 160 180 12
19 22 180 88 56</pre><p>now I need to make a code that will look for any value>=150 and also look for 4 neighbor coordinates and if it gets any other value of >=150 it will consider that coordinates as same group and store a number like 1 for that group and then move to next point and repeat the same.
How can I make this?</p>Nine/matlabcentral/answers/contributors/5646930ninetag:www.mathworks.de,2005:Question/15467320140913T19:43:37Z20140916T02:13:01ZFrame will not update with Live Video Tacking <p>Hello Everyone!
I need some help...
I'm working on a project that will track the position of a particle using a live video feed and frame capture. To start I created a custom GUI with the help of this tutorial:</p><p><a href = "http://www.mathworks.com/matlabcentral/answers/96242howcaniinsertlivevideointoamatlabguiusingimageacquisitiontoolbox">http://www.mathworks.com/matlabcentral/answers/96242howcaniinsertlivevideointoamatlabguiusingimageacquisitiontoolbox</a></p><p>I then added to the captureImage_Callback function to perform some image processing techniques and a for loop to capture 10 frames.</p><p>The issue that I am having now is that when I press the pushbutton "captureImage" The program does indeed capture 10 frames. However it is capturing the same frame 10 times. Is there a way I can have MATLAB update the frame to be captured so that I have subsequent frames instead of the same frame 10 times?</p><p>I apologize with my lack of experience with custom GUI's. I haven't done much work with them. attached is my code.</p><p>Thank you in advance!</p>John/matlabcentral/answers/contributors/5468353johntag:www.mathworks.de,2005:Question/15496320140916T01:59:29Z20140916T02:42:39ZMatlab connector error from simulink message viewer<p>I am trying to run a demo file given by Mathworks expo but error messages pop up as below.</p><p>Warning:Failed to activate MATLAB Connector: Error starting MATLAB connector. Please check taht port 31515 is available.
Error using slmsgviewer.startConnectorIfNotRunning (line 455)
Unable to start Matlab connector from Simulink Message Viewer</p><p>I hope helpful commensts from members.
Thanks</p>Jay Son/matlabcentral/answers/contributors/5185767jaysontag:www.mathworks.de,2005:Question/15495820140915T23:45:12Z20140916T01:58:26ZSpring Mass Problem  Code not working<p>I am trying to learn to model with matlab. I started at the symbolic math toolbox and went through the <b>MassSpringDamper System Modeling</b>. The link is given here</p><p><a href = "http://www.mathworks.com/products/symbolic/codeexamples.html?file=/products/demos/symbolictlbx/Mass_Spring_Damper/MSD_published.html">http://www.mathworks.com/products/symbolic/codeexamples.html?file=/products/demos/symbolictlbx/Mass_Spring_Damper/MSD_published.html</a></p><p>However, the code given there starts to give error. What am I doing wrong?</p><p>My input was (as copied from the link)</p><pre class="languagematlab">f1 := ode({m*x''(t) + R*x'(t) + k*x(t), x(0) = 0 , x'(0) = 1}, x(t))
</pre><p>The error I received was</p><pre class="languagematlab">f1:= ode({m*x''(t) + R*x'(t) + k*x(t), x(0) = 0 , x'(0) = 1}, x(t))

Error: The expression to the left of the equals sign is not a valid
target for an assignment.
</pre><p>Can someone tell me what i am doing wrong?</p>Rupak Banerjee/matlabcentral/answers/contributors/1206943rupakbanerjeetag:www.mathworks.de,2005:Question/15495720140915T23:42:02Z20140916T01:54:22ZHow to reduce number of entries in legend<p>I am plotting 9 curves from the following 9 vectors.</p><p>r_t1 , g_t1 , b_t1
r_t2 , g_t2 , b_t2
r_t3 , g_t3 , b_t3</p><p>My color choice is
rred
ggreen
bblue</p><p>and marker is</p><p>t1  '+',
t1  '*',
t1  'o'</p><p>So instead of having '9' entries in legend, I want only 6. 3 indicating r,g,b and 3 indicating t1,t2,t3</p><p>How can i do this?</p>xplore29/matlabcentral/answers/contributors/3184454xplore29tag:www.mathworks.de,2005:Question/15494620140915T21:48:04Z20140916T01:41:32Z??? Index exceeds matrix dimensions. <p>I have a matlab file (mfile) with the operation for spatial regression from my teacher (I also have a .txt file data333 for all data of sample points), it looks like this:</p><p>%*********Spatiell regression********
%***This program calculates a new value (z*) for each value (zi)in a table and
%***account for all other values (zj). These other values (zj)are weighted with the
%****squared distance (1/d^2).
%***In this version, we only use values that are within a specific radius
%***chosen by the user. e.g "d<30"
%***The program calculates new z for the same number of columns that the input file has got.
%***
%
%
%
%
%
clear
format long
%
load C:\tempdata\data333.txt
col=0;
raa=0.05;
d=0;
c=0;
n=0;
w=0;
b=0;
data4=zeros(220,10);</p><p>for col=3:12</p><pre> for i=1:220
b=0;
c=0;</pre><pre> for j=1:220
if i~=j
d=sqrt((data333(i,1)data333(j,1))^2+(data333(i,2)data333(j,2))^2);
if d<30
c=(1/(d^2))*data333(j,col);
b=b+c;
else
end</pre><pre> end
end</pre><pre> x=data333(i,col)  (raa * b);
n=i;</pre><pre> data4(i,col)= x;
data4(i,1)=n;</pre><pre> end</pre><p>% dlmwrite('trash.txt',data4,'\t')
dlmwrite('data333100spreg2raa05.txt',data4,'\t')
end</p><p>I thus just copied those steps except I wrote data333=importdata ('C:\tempdata\data333.txt'） instead of use Load. This is because everytime I use Load, I got error messages :"Undefined function or variable xxx" or "Undefined function or method 'data333' for input arguments of types 'double' ” etc.</p><p>After I wrote data333=importdata ('C:\tempdata\data333.txt'）I got:
data333 =</p><pre> data: [220x12 double]
textdata: {'x' 'y' 'DEM' 'asp' 'grad' 'DAI2' 'HI' 'VI' 'SLI2' 'Yield' 'DAI1' 'SLI1'}
colheaders: {'x' 'y' 'DEM' 'asp' 'grad' 'DAI2' 'HI' 'VI' 'SLI2' 'Yield' 'DAI1' 'SLI1'}</pre><p>Then I copied the rest and ran MATLAB, an error message appeared:
Index exceeds matrix dimensions.</p><p>I never used MATLAB before and suddently I have to hand in this assignment within 3 days! Could somebody help me to figure it out? Thanks!!!</p><p>Yaoyao</p>Yaojiayin/matlabcentral/answers/contributors/5643032yaojiayintag:www.mathworks.de,2005:Question/15495520140915T23:28:19Z20140916T01:33:08ZGenerating days based on leap years<p>Hi,</p><p>I wanted to generate a matrix like below. Basically, years in the first column, start days, end days for the year by conditional check of first column. Fourth row is basically MOD function to check if a leap year or not.</p><pre class="languagematlab">1960 1 366 366
1961 367 731 365
1962 732 1096 365
1963 1097 1461 365
1964 1462 1827 366
1965 1828 2192 365
1966 2193 2557 365
. . . .
2014
</pre><p>Does anybody have an idea?</p><p>Thanks in advance.</p>Damith/matlabcentral/answers/contributors/5131512damithtag:www.mathworks.de,2005:Question/15458620140912T22:29:58Z20140916T01:31:47ZFFT not working on periodic data!?!?!?<p>Hello,</p><p>I have data which, when visualized,, displays some very periodic behavior (picture a 2D sine wave). However, when I call the fft2() function on my matrix I only get the zerofrequency bin to be nonzero. I would have expected the very clear periodicity in my data to become clear in the FFT, but it seems that somewhere something's going wrong!</p><p>Any ideas, including common mistakes or misunderstandings with fft2 or FFTs in general?</p><p>Actually, it's quite weird that, regardless of my data, I only get the zerofrequency bin lighting up in the fft!!</p><p>code: (msum2 is my real data)</p><p>zMapT2=fftshift(fft2(msum2));</p><p>zMapAbs=abs(zMapT2);</p><p>imagesc(zMapAbs);</p><p>so I'd expect to see some bins lighting up away from the origin, but everything's blue except for the red at the center.</p>Bruce/matlabcentral/answers/contributors/4723513brucetag:www.mathworks.de,2005:Question/15482520140915T00:33:57Z20140916T01:27:25ZHi, my current code is written for time responses using the lsim function but it needs to be converted to ode45 and i have no idea where to start. Here's my current code with lsim, andy help would be appreciated!<p>% Elevator deflection code</p><p>A=[.045 .036 0 32.2;.369 2.02 176 0;.0019 .0396 2.948 0;0 0 1 0];</p><p>B=[0;28.17;11.88;0];</p><p>C=eye(4);</p><p>D=[0;0;0;0];</p><p>values=eig(A);</p><p>T = 0:1:200;</p><p>U = ones(size(T));</p><p>sys = ss(A,B,C,D);</p><p>[Y, Tsim, X] = lsim(sys,U,T);</p><p>plot(Tsim,Y)</p><p>Y1=(Y(:,1)./176.)/57.7</p><p>Y2=Y(:,2)./176</p><p>newY= [Y1 Y2 Y(:,3) Y(:,4)]</p><p>subplot(2,2,1)</p><p>plot(Tsim,Y1)</p><p>ylabel('delta(u)/V')</p><p>xlabel('Time (s)')</p><p>subplot(2,2,2)</p><p>plot(Tsim,Y2)</p><p>ylabel('delta(alpha)(deg)')</p><p>xlabel('Time (s)')</p><p>subplot(2,2,3)</p><p>plot(Tsim,Y(:,3))</p><p>ylabel('q(deg/s)')</p><p>xlabel('Time (s)')</p><p>subplot(2,2,4)</p><p>plot(Tsim,Y(:,4))</p><p>ylabel('delta(theta)(deg)')</p><p>xlabel('Time (s)')</p>Jon Miller/matlabcentral/answers/contributors/5641272jonmillertag:www.mathworks.de,2005:Question/13020820140519T16:24:14Z20140916T01:25:54ZR2014a windows 8.1 64bit setup.exe doesn't install matlab<p>I just downloaded R2014a 64bit for my Win8.1 laptop. I get the .exe which unzips itself into _temp_matlab_R2014a_win64</p><p>I go into this folder and run setup.exe.</p><p>It proceeds to do the Microsoft C++ Redistributable thing and then nothing. The window just closes and then nothing happens. No error, nothing. I've checked for a background process, run as an admin and moved the folder out of downloads.</p><p>The instructions say that I need to log into the installer with my mathworks id and such, but it doesn't get to that point.</p><p>Thanks in advance for any help/advice. I need this for a project so semiurgent.</p>Gerald/matlabcentral/answers/contributors/5340885geraldtag:www.mathworks.de,2005:Question/15458920140913T00:25:03Z20140916T01:14:41ZHow to automatically scroll a textbox to end of line?<p>Hi all,</p><p>I'm trying to code a calculator, which has an inactive (noneditable) textbox used for display of the input. Is there a way to automatically scroll the textbox to the end when the input gets longer than the width of the textbox? (If it's impossible in matlab maybe there's some workaround in java?)</p><p>Thanks!</p><p>Niko</p>Niko/matlabcentral/answers/contributors/4630773nikotag:www.mathworks.de,2005:Question/15493820140915T20:18:22Z20140916T01:05:58Zhow to make my data appear in more accurate way ?<img src = "/matlabcentral/answers/uploaded_files/18194/untitled.jpg"><p>my data appear like this after i plot it, i know that mean there are a big deference between the data but i want to see the low data so should i make filter and how i do it ?</p>aliaa madbouly/matlabcentral/answers/contributors/3878507aliaamadboulytag:www.mathworks.de,2005:Question/7643020130520T17:46:01Z20140916T00:55:54ZSimulink Dynamic Popup Parameter Values Set at Mask Initialization<p>I am trying to populate an SBlock Simulink Mask's parameter with a list of files from a specific directory. It seemed to me the best way to do this would be to set up the parameter as a 'popup' type, and give it some acceptable initial values in the 'popups' typespecfic options, and then use the Mask Initialization code to overwrite these with the full list.</p><p>The code I am currently trying to use looks like this:</p><pre class="languagematlab">directory_to_list = what('Some Directory on the Search Path');
p = Simulink.Mask.get(gcb);
a = p.Parameters(13); %note it is the 13th parameter of this mask
a.set('TypeOptions', directory.mat); %drop in a cell array listing of .mat files
</pre><p>This produces the error message:</p><pre class="languagematlab">Error in 'blockname'. Initialization commands cannot be evaluated.
Caused by:
Invalid inputs specified for method 'set'. Attempt to modify mask parameter name of block 'blockname' in its Mask Initialization. Changing mask parameter name as part of MaskInitialization is not allowed.
</pre><p>I've replaced my blockname with the dummy name 'blockname' above to keep the issue generic.</p><p>I tried some additional things such as:</p><pre class="languagematlab">directory_to_list = what('Some Directory on the Search Path');
p = Simulink.Mask.get(gcb);
a = p.Parameters(13); %note it is the 13th parameter of this mask
a.set('Name', 'same name of block', 'TypeOptions', {'red', 'blue'});
</pre><p>and even a simple test like:</p><pre class="languagematlab">p = Simulink.Mask.get(gcb);
a = p.Parameters(13); %note it is the 13th parameter of this mask
a.set('Visibility', 'off');
</pre><p>and I always get the same error message. Clearly either I am making some important mistake, or this is not an allowed way to change the popup's option list. Is there a better way to do this?</p><p>Finally, as I'm sure this question will come up, I <i>have checked</i> the "Allow library block to modify its contents" box on the initialization tab.</p><p>Thoughts? Suggestions? Anything would be helpful.</p>Alex/matlabcentral/answers/contributors/1607253alextag:www.mathworks.de,2005:Question/15495620140915T23:30:09Z20140916T00:54:20ZHow can I plot multiple 3d surface from three 4d matrices generated from ndgrid()<p>How can I plot multiple 3d surface from three 4d matrices generated from ndgrid()</p><pre class="languagematlab">i1 =linspace(90*pi/180,90*pi/180,10);
i2 =linspace(10*pi/180,10*pi/180,10);
i3 =linspace(12*pi/180,12*pi/180,10);
i4 =linspace(90*pi/180,0*pi/180,10);
[L1,L2,L3,L4]=ndgrid(i1,i2,i3,i4);
%khaledts_x,khaledts_y,khaled_z are three function to transfer L1,L2,L3,L4 to x,y,z
</pre><pre class="languagematlab">x=khaledts_x(0,0,0,L1,L2,L3,L4);
y=khaledts_x(0,0,0,L1,L2,L3,L4);
z=khaledts_x(0,0,0,L1,L2,L3,L4);
</pre><pre class="languagematlab">surf(x,z,y);
but surf function can't plot it
</pre>khaled Foda/matlabcentral/answers/contributors/5585370khaledfodatag:www.mathworks.de,2005:Question/15495220140915T22:52:37Z20140916T00:54:00ZHow To plot areas like: f(x) > mx +b ???<p>Hi everyone,</p><p>I'm trying to plot functions directly from FPLOT...</p><p>For instance:</p><pre class="languagematlab">fplot(@(x)10*x, [10 10]);
</pre><p>BUT How can i plot "filled" graphs to indicate <b>f(x)>10x</b> or <b>f(x)<10x</b></p><p>Thanks in advance!</p>F/matlabcentral/answers/contributors/5210121ftag:www.mathworks.de,2005:Question/15496120140402T04:00:00Z20140916T00:51:02ZWhy does Microsoft Windows SDK 7.1 not get detected as a supported compiler for Windows 8 with Framework 4.5?<p>I have installed the supported compiler MICROSOFT WINDOWS SDK 7.1 on my machine Windows 8 which has .NET Framework 4.5. However MEX fails as it is not being able to detect a supported compiler.</p>MathWorks Support Team/matlabcentral/answers/contributors/4622813mathworkssupportteamtag:www.mathworks.de,2005:Question/15385920140907T03:15:43Z20140916T00:49:46Zthe variable can't be classified with parfor<p>I have large code and need fix the error of variable(perror) as can't be classified and I can summarized my code.</p><p>ind=1; indx =1; limit=4; % Opening the output file</p><p>fid=fopen('Parallel_k_n_L_test_16_6_2014.txt','wt');</p><p>parfor SNR=0:5</p><pre> undetected_errors = 0;
SNR
frmerror=0;
bitnerr=0;
frames=0;
.
.
.
.
% Decoder 
[success,kr,dd0,x_hat1]=turbo_decoder_infectious_no_int_z_9_6_2010(rcv,si,H1,co,fid,frames);
% 
dseq1=dd0;
% B E R 
error=sum(abs(dseq1b));
perror1=error/size(b,2);
perror(frames)=perror1; %(the problem here)
if error~=0
frmerror=frmerror+1
bitnerr=bitnerr+error;
if success == 1
undetected_errors = undetected_errors +1;
c_w(indx,:) = co;
noise_w(indx,:) = noise;
b_w(indx,:) = b;
kr_w(indx,:) = kr;
x_hat1_w(indx,:) = x_hat1;
indx = indx +1;
end
end
merror=mean(perror);
ferror(ind)=merror;
frmerr(ind)=frmerror;
ind=ind+1;
bits=frames*size(G1,1);
BER=bitnerr/bits
FER=frmerror/frames
end
fclose('all');
semilogy(SNR,BER);</pre><p>the result un error as the variable perror can't be classified</p><p>so plz can anyone help me fix the problem me make other other variables and shall need matlabpool for high speed? also my program working well for.</p>Ahmed/matlabcentral/answers/contributors/4777229ahmedtag:www.mathworks.de,2005:Question/15443520140911T22:01:33Z20140916T00:48:33Zhow to solve the following Probability density function in matlab?<p>Hello, i am very new to Matlab and got this question in assignment which i need to submit soon. Any help with coding and a bit explanation would be appreciated.</p><p>A probability density function (PDF) is given as follows:</p><pre> 1/4 0<=x<3
f(x) =
5/8(1/8)x 0<=x<=5</pre><ol><li>Plot the PDF in Matlab.</li><li>Calculate and plot the CDF.</li><li>Demonstrate analytically that the mean value associated with the PDF
is 49/24.</li></ol><p>The answer to the question should be the plots of the PDF and the CDF,
as well as the analytical calculation of the mean value.</p>Hydro/matlabcentral/answers/contributors/5628601hydrotag:www.mathworks.de,2005:Question/15495920140915T23:47:10Z20140915T23:50:40ZThe general solution to a second order differential equation with complex roots is a sinusoid multiplied by an exponential of the form.x(t) = e^at(cos(2πft+θ). For all of the plots below, be careful to choose a range of time axis values that displays<p>A)Plot a signal whose amplitude envelope never decays, oscillates 3 times per second, and has a phase shift of π/2</p>PADMA gazula/matlabcentral/answers/contributors/5614189padmagazulatag:www.mathworks.de,2005:Question/15482720140915T01:16:21Z20140915T23:44:39ZHow to assess adequacy of fitted GARCH model?<p>I am curious how to check whether an already fitted GARCH or ARIMA model with GARCH variance adequately captures the data it is fitted to, not whether one GARCH model is a better fit than another.</p><p>For example, after fitting an ARIMA model with constant variance to a time series Y, we can use the infer function with the data set Y and the fitted ARIMA model to retrieve the residuals, which, if the model is an adequate fit, should be a white noise process.</p><p>I am unsure how, after fitting a GARCH model with the estimate function, I can check the adequacy of the fit by, say, looking at the residual series. When the infer function is used with a GARCH model, it does not return a residual series so it seems similar analysis to that above may not be able to be performed. Please offer suggestions on how a fitted GARCH model may be tested to see whether it adequately describes (is fit to) a dataset. Thank you.</p>Danny/matlabcentral/answers/contributors/3318675danny