http://nl.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2015-01-26T20:29:09Ztag:nl.mathworks.com,2005:Question/1720302015-01-26T19:04:46Z2015-01-26T20:24:49ZIs It possible to creare a GUI within a GUI? <p>Is it possible to create another GUI from within the callback function of an existing GUI?</p>Ipsitahttp://nl.mathworks.com/matlabcentral/profile/authors/5587284-ipsitatag:nl.mathworks.com,2005:Question/1712992015-01-23T11:37:45Z2015-01-26T20:19:48ZHow can I filter white noise to obtain signal with desired PSD?<p>I need to generate various of signals with different PSD (power spectral density) and PDF (probability density function). My input data are only shapes of this two functions and my idea is to generate random numbers of given PDF and after that I will filter the data to signal with desired PSD. It is no problem for me to obtain the random numbers. I am asking only for the filering to desired PSD.</p><p>Any tips are welcome.</p><p>Regards,
Adam</p>Adam Nieslonyhttp://nl.mathworks.com/matlabcentral/profile/authors/869547-adam-nieslonytag:nl.mathworks.com,2005:Question/1719102015-01-26T09:38:02Z2015-01-26T20:19:45ZHow can I fix a "Subscripted assignment dimension mismatch."<p>hi, my project is about atrial fibrillation
I want to use butterworth method to filter out the signal, however when i use filtfilt it keep saying "Subscripted assignment dimension mismatch" which didnt occur in the first few runs</p><p>Can someone please help me</p><p>Thanks</p><pre> %% Signals with no fitler
Virtuals = loadmat('LA_D_001_PRE_subtracted_VIR.mat');
Virtuals = Virtuals';</pre><pre> subplot(3,1,1);
plot(Virtuals);
title('Signals with no filter');
xlabel('Time');</pre><pre> %% Applying with Butterworth filters
X = Virtuals;
%First order
[b, a]= butter(1, [4/256 10/256]);
%% Filtfilt
for i=1:2048
Y2(i,:)=filtfilt(b,a,X(i,:));
end</pre><pre> subplot(3,1,2);
gplot(Y2,b);
hold on;
gplot(Y2,a);
hold off;
title('signals with Butterworth filter - First order');
xlabel('Time');</pre><pre> %% phase
A= Y2';
% waitbar(6/8)
% [r c]=size(A);
% Phase=zeros(size(A));
for j=1:size(A,1)
s=squeeze(A(j,:));
s=s-mean(s);
ha=imag(hilbert(s));
Phase(j,:)=-atan2(ha,s);
end
clear A</pre>tram nguyenhttp://nl.mathworks.com/matlabcentral/profile/authors/5921780-tram-nguyentag:nl.mathworks.com,2005:Question/1720332015-01-26T19:41:49Z2015-01-26T20:16:15ZIssue with 2014 b version of MATLAB<p>Hello, i have a code written for 2012 verison of MATLAB which works fine witht he old version.</p><p>the new version gives an error says stack overflow and other issues. basically not able to rea code properly. Can someone please help me wiht this?</p><p>thanks</p>PRATIK JAISWALhttp://nl.mathworks.com/matlabcentral/profile/authors/6105712-pratik-jaiswaltag:nl.mathworks.com,2005:Question/1720362015-01-26T20:02:57Z2015-01-26T20:13:40ZHow can I plot a root locus for an open loop system?<p>Hi,</p><p>I need help in plotting an open loop system for the following equation:</p><p>G(s)=K / s[(Is+a)(Hs+R) +K^2]</p>sonihttp://nl.mathworks.com/matlabcentral/profile/authors/5883255-sonitag:nl.mathworks.com,2005:Question/1720232015-01-26T18:03:08Z2015-01-26T20:12:29ZHow to find the variance of an image in a special windows? variance(in 3*3 windows)<p>I obtain mean of image like this</p><pre class="language-matlab">if true
function [ I2] = mean3dar3( m )
h = fspecial('average', [3 3]);
I2 = imfilter(m,h);
</pre><p>end</p><p>I want to obtain variance of image in a special windows like mean but I dont know how can I make filter of this...
thanks</p><pre class="language-matlab">end
</pre>sarahttp://nl.mathworks.com/matlabcentral/profile/authors/5590407-saratag:nl.mathworks.com,2005:Question/1720372015-01-26T20:07:51Z2015-01-26T20:08:29ZMatlab finding builtin file before class method file of same name<p>I am working with an existing code package (Aparat-0.3.1) for speech signal analysis. However, they have created their own filter.m that applies to classes @signal, using different parameters from the normal Matlab filter command.</p><p>Currently, when called, Matlab finds the builtin function filter from the below address:</p><p>"built-in (C:\Program Files\MATLAB\R2013a\toolbox\matlab\datafun\@single\filter) % single method"</p><p>instead of finding the class function @signal/filter.m, which is stored a few folders down from my original directory.</p><p>What type of command can I use to tell it where to look? I can't be solely in that folder as my main directory as I need to access other folders just a few lines later in my main call file.</p><p>In most other scenarios, I do what the normal builtin "filter" command to be the first one found.</p><p>Thanks for any assistance you can provide!</p>Stephaniehttp://nl.mathworks.com/matlabcentral/profile/authors/3440542-stephanietag:nl.mathworks.com,2005:Question/1720322015-01-26T19:16:38Z2015-01-26T19:58:51ZHow to use the find function discover the row and column [pixel coordinates] of all the blue pixels per column?<p>I’m having problems using the find function to discover the row and column [pixel coordinates] of the blue pixels.</p><p>What I want to do is find the first and last blue pixels these will correspond to the boundaries of the lumen where I want to paint the range between these first and last boundaries in blue, per column. But in some column values I have the bifurcation of the vessel, and here again I want to find the first and last blue pixel of the bifurcation (between the first and last blue pixels found for lumen) and paint the range between these values in black.</p><p>I was able to find the first and last blue pixels using the code below (but without using the row value jj), only with movingRegistered(:,zz,3)==).</p><ol><li>First I don’t understand why it only works with (: )</li><li>But using the same logic to find the first and last bifurcation values between the values found, appears the error:
Subscripted assignment dimension mismatch</li></ol><p>I tried to make :</p><pre class="language-matlab">(movingRegistered- 499x631x3 uint8
Bif_firt(1x631)
Bif_last(1x631)
</pre><pre class="language-matlab">bif_first(1,zz)=find((movingRegistered(jj,zz,1)==0 & ...
movingRegistered(jj,zz,2)==0 & ...
movingRegistered(jj,zz,3)==255),1,'first'); % the first blue row for that column
bif_last(1,zz)=find((movingRegistered(jj,zz,1)==0 & ...
movingRegistered(jj,zz,2)==0 & ...
movingRegistered(jj,zz,3)==255),1,'last'); %the last blue row for that column
</pre><p>But it only appears 1 in every column.</p><pre class="language-matlab">3-Does anybody have any suggestion?
4- I tried to paint the image with blue and the rest with black but my figure (13) appears the same as before, what I’m doing wrong? Please see my code below:
</pre><pre class="language-matlab">%% Find the countour indexes and paint the lumen in blue %%%%%%
lumen_first=zeros(1,size(movingRegistered,2));
lumen_last=zeros(1,size(movingRegistered,2));
bif_first=zeros(1,size(movingRegistered,2));
bif_last=zeros(1,size(movingRegistered,2));
lumen=false;
for zz=1:1:size(movingRegistered,2);%columns
for jj=1:size(movingRegistered,1);%rows
if(movingRegistered(jj,zz,1)==0 && ...
movingRegistered(jj,zz,2)==0 && ...
movingRegistered(jj,zz,3)==255)
lumen=true;
lumen_first(1,zz)=find((movingRegistered(:,zz,1)==0 & ...
movingRegistered(:,zz,2)==0 & ...
movingRegistered(:,zz,3)==255),1,'first'); % the first blue row for that column
lumen_last(1,zz)=find((movingRegistered(:,zz,1)==0 & ...
movingRegistered(:,zz,2)==0 & ...
movingRegistered(:,zz,3)==255),1,'last'); %the last blue row for that column
end
end
end
for zz=1:1:size(movingRegistered,2);%columns
for jj=lumen_first(1,zz)+4:lumen_last(1,zz)-1;%rows
bifurcacao=false;
if (movingRegistered(jj,zz,1)==0 && ...
movingRegistered(jj,zz,2)==0 && ...
movingRegistered(jj,zz,3)==255)
bifurcacao=true; %existis bifurcation
bif_first(1,zz)=find((movingRegistered(jj,zz,1)==0 & ...
movingRegistered(jj,zz,2)==0 & ...
movingRegistered(jj,zz,3)==255),1,'first'); % the first blue row for that column
bif_last(1,zz)=find((movingRegistered(jj,zz,1)==0 & ...
movingRegistered(jj,zz,2)==0 & ...
movingRegistered(jj,zz,3)==255),1,'last'); %the last blue row for that column
end
end
end
rgbImage_blue=movingRegistered;
%%Paint in blue the lumen region
%Verify if where vector lumen_first has 0 values
zmin_lumen=find(lumen_first(:),1,'first');%column value
zmax_lumen=find(lumen_last(:),1,'last');%column value
lumen_green=zeros(size(movingRegistered));
for z=zmin_lumen:zmax_lumen
for j1=lumen_first(1,z):lumen_last(1,z);
lumen_green(j1,z)=1;
end
end
for zz=1:size(rgbImage_blue,2);
for jj=size(rgbImage_blue,1);
if lumen_green(jj,zz) ==1;
rgbImage_blue(jj,zz,1)=0;
rgbImage_blue(jj,zz,2)=0;
rgbImage_blue(jj,zz,3)=255;
else
rgbImage_blue(jj,zz,1)=0;
rgbImage_blue(jj,zz,2)=0;
rgbImage_blue(jj,zz,3)=0;
end
end
% if bifurcacao,
% for j2=bif_first(1,zz):bif_last(1,zz)
% rgbImage_blue(j2,zz,1)=0;
% rgbImage_blue(j2,zz,2)=0;
% rgbImage_blue(j2,zz,3)=0;
% end
end
figure(13),imshow(rgbImage_blue);
</pre>Helena Henrqueshttp://nl.mathworks.com/matlabcentral/profile/authors/3424241-helena-henrquestag:nl.mathworks.com,2005:Question/1719932015-01-26T16:20:26Z2015-01-26T19:59:16ZArrange Matrix - Same Values of a Row to one Column<p>Hello,
I have a huge database that needs to be re-arranged:</p><pre class="language-matlab">System_Values ; System_Name
1 ; ABC1
3 ; ABC2
8 ; ABC1
7 ; ABC3
0 ; ABC1
5 ; ABC3
8 ; ABC2
4 ; ABC3
7 ; ABC2
6 ; ABC2
</pre><p>So as you can see there are three different system names ABC1..3.
ABC1 for example has several values in the first column: 1,8 and 0.
I want matlab to find the systems and adding the values of each system in one column:</p><pre class="language-matlab">ABC1 ; ABC2 ; ABC3
1 ; 3 ; 7
8 ; 8 ; 5
0 ; 7 ; 4
empty ; 6 ; empty
</pre><p>I have absolutely no idea how to do this in a matlab script.
I hope you can help me, please let me know if you don`t understand my problem.</p><p>Thanks</p>Marv Rishttp://nl.mathworks.com/matlabcentral/profile/authors/6104772-marv-ristag:nl.mathworks.com,2005:Question/1720352015-01-26T19:55:37Z2015-01-26T20:29:09ZFilters to Equalize Flicker noise<p>Hi,</p><p>I have been acquiring data between 0.1 to 50 KHz using an ADC and saving data to computer. From plotting the data in Matlab and looking at the FFT (via fvtool), I noticed that I have flicker noise (fc = 1Hz estimate), I was wondering if there are simple algorithms (libraries, functions) in Matlab to help me equalize the noise across the frequency range say via a FIR filter (or multiple FIR filters) so that I can port it to the embedded system. Any advice or links to algorithms related to flicker noise would be appreciated too (as I can't seem to find many online), also I am wondering if there any trade-offs of using equalization and if they would impact my signals of interest considering this is post-processing.</p><p>PS: for my project, my goal is to have a flat noise bed across this frequency range (Fs = 128KHz)</p><p>Thank you.</p>Daoyuanhttp://nl.mathworks.com/matlabcentral/profile/authors/5106762-daoyuantag:nl.mathworks.com,2005:Question/1720342015-01-26T19:53:58Z2015-01-26T19:53:58ZI was doing the following , it tells me the following: "'The variable 'non ' ,'list' appear to change size on every loop. Consider preallocating for speed"<p>If TF==1
n=n+1; List(n,:)=tmp2;
non(n)=lengh(index1);
for h=1:non(n), nodes1(n,h)=index(h);
End;
End;</p>Zainab Alobaidihttp://nl.mathworks.com/matlabcentral/profile/authors/6105695-zainab-alobaiditag:nl.mathworks.com,2005:Question/1717352015-01-25T20:39:43Z2015-01-26T19:49:03Zhow can obtain min of matrix<img src = "/matlabcentral/answers/uploaded_files/24401/Untitled.jpg">sarahttp://nl.mathworks.com/matlabcentral/profile/authors/5590407-saratag:nl.mathworks.com,2005:Question/1677402014-12-22T19:24:51Z2015-01-26T19:39:43Zsystem() call on windows, R2012b & R2014b, handling error popups<p>Hi</p><p>I try to run an external program via system() call. In a normal command shell and execute from R2012b everything works as expected, in R2013b nothing happens and my status after the system call is "-1.0737e+09" (return is empty). Same behavior if I open a cmd prompt in matlab R2013b (system('cmd')) and try to start it there.</p><p>It seems like some dependency/library of the external software is not found, because if I rename the folder of one of the needed dependencies, I get the exact same behavior in R2012b. If I than run the command directly in a cmd-prompt, a msg-box error with the unavailable dependency pops up, which matlab probably cannot return?</p><p>I tried to compare every environment variable between R2012b and R2013b (by the way R2014b does not work, either) but java.lang.System.getenv() returns exactly the same values for both Matlab versions, except __COMPAT_LAYER (ElevateCreateProcess vs. DisableUserCallbackException), but setting the environment variable in R2013b to the same value as in 2012 does not solve the problem for me.</p><p>Is there any other difference between the system call in R2012 compared to R2013? Or compared to a "normal" cmd prompt?</p><p>win7 64bit, same system (i.e. hardware) for both versions</p><p>any ideas?</p>Stefanhttp://nl.mathworks.com/matlabcentral/profile/authors/4891217-stefantag:nl.mathworks.com,2005:Question/1720312015-01-26T19:12:25Z2015-01-26T19:36:37Zsystem file watch crash<pre class="language-matlab">fsw = System.IO.FileSystemWatcher();
fsw.Path = 'C:\Users\wolfgang\Desktop';
fsw.Filter = 'NZDUSD1.csv';
fsw.EnableRaisingEvents = true;
listenerhandle = addlistener(fsw, 'Changed', @(~,~)importfcn(q,a));
%signature of importfcn is function importfcn(sender, eventargs)
%add a small delay in importfcn before reading the file as the event is raised
%to make sure that file modification is complete
</pre><p>When I run this file, .csv file gets imported every minute and then processed. Sometimes, the imported file is still processed and the next import is delayed. This leads to the delay of several files.</p><p>In the end my matlab crashed and I get an error message. How can I resolve this problem?</p>AAhttp://nl.mathworks.com/matlabcentral/profile/authors/5703029-aatag:nl.mathworks.com,2005:Question/1713662015-01-23T22:51:48Z2015-01-26T19:07:05ZHow do you declare structures within classes?<p>I want to nest a class inside of a class or a struct inside of a class:</p><pre class="language-matlab">classdef class1
</pre><pre> properties
Commands = struct(...
'functionResetTime' ,1,...
'CtrlTestData' ,9 ...
)
x =3;
end
methods
end</pre><pre class="language-matlab">end
</pre><p>I want to do this because I have about 20 structs that I would like to use the automatic tooltyping (. and then tab) when I write code. Kind of like .net. I don't want to have to create a file for each of these structs or import them. The method describe above doesn't work and you can't just declare a struct anymore (why? I don't know).</p>Stevenhttp://nl.mathworks.com/matlabcentral/profile/authors/3784663-steventag:nl.mathworks.com,2005:Question/1720172015-01-26T17:38:36Z2015-01-26T19:06:22Zproblem finding minimum of residual for separable nonlinear least square using fminsearch<p>Dear All,
I have some ultrasonic signal that I created wavelet transform for.
I am trying to do separable nonlinear least square between measured signal(function of time and frequency) and reference model.
to get the maximization criterion I made derivation for different equations and reshaping of the matrix to be a vector instead of a matrix in order to match fminsearch. Please find attached for the equations required to perform for the maximization criterion
the final model I needed to maximize is shown below:</p><p>I tried to use fminsearch function to get the minimum value of t_center but I can not get any solution. it says:
Exiting: Maximum number of function evaluations has been exceeded
- increase MaxFunEvals option.
I already increased MaxFunEvals and MaxIter to 1000 but still not possible.
Please find below the code I made and tell me what is wrong with it.
I already attached the m-file for better reading of the code.</p><pre class="language-matlab">function max_criterion = myfun(t_center)
global F s
w=2*pi*F';
t=linspace(0,0.015,3000);
w_center=2*pi*200000;
w1=2*pi;
eeta=w./w1;
Y=s;
B=100000;
A=1/2.*sqrt((2.*eeta)./(pi.*(B^2+4.*eeta.^2)).*exp(-2.*(w-w_center).^2./(B.^2+4.*eeta.^2)));
k= -B.^2.*eeta.^2./(2.*(B.^2+4.*eeta.^2))*(t-t_center).^2;
kai= ((4*w_center*eeta.^2)./(B^2+4.*eeta.^2)+B^2.*w./(B^2+4.*eeta.^2))*(t_center-t);
Z=repmat(A,1,length(t));
H=Z.*exp(k).*exp(1i.*kai);
H_new=(reshape(H,numel(H),1));
Y_new=(reshape(Y,numel(Y),1));
max_criterion= -1000000000.*Y_new'*H_new*((H_new'*H_new)\H_new')*Y_new;
end
</pre><p>then I am trying to use fminsearch function to extract the local minimum but it never give a solution:</p><pre class="language-matlab">options=optimset('tolx',1e-18,'tolfun',1e-18,'MaxFunEvals',1000,'MaxIter',1000);
t_center_ini = 0.000591;
[t_center,fval,exitflag,output] = fminsearch(@myfun,t_center_ini,options)
</pre><p>I tried to use function "fminbnd" and it gave results but I am afraid to use because it works only with continuous functions and may be the wavelet transform have discontinuities.</p><p>Can you please help me with that. what is the mistake I do.
Best Regards,
Hossam Selim</p>hosamhttp://nl.mathworks.com/matlabcentral/profile/authors/1875530-hosamtag:nl.mathworks.com,2005:Question/1720292015-01-26T19:02:43Z2015-01-26T19:04:19ZC compilation from Unix to Windows with MEX (2014b)<p>I am trying to compile a Unix-created C file on a Windows machine. The source code and all its dependencies compile and work fine on the Unix computer outside of Matlab, but as soon as I import the files to Windows and try to compile with MEX, I get a link error saying it cannot find a .lib file:</p><pre class="language-matlab">LINK : error LNK2001: unresolved external symbol mexFunction
irt_to_utc.lib : fatal error LNK1120: 1 unresolved externals
</pre><p>I do have a .so file, though when I tried including it in the MEX command, I got another link error:</p><pre class="language-matlab">Error using mex
lib_sng_time.so : fatal error LNK1107: invalid or corrupt file: cannot read at 0xFE10
</pre><p>All of the appropriate dependencies are in the files and headers, so can I force MEX to compile without a .lib file? Can MEX be configured to accept .so files instead of .lib files? Maybe I am misinterpreting how MEX works.</p><p>Thanks for the help</p><p>I'm pretty new to Matlab and even newer to C compilation, so I apologize if this is not clear.</p>Brett Goodwinhttp://nl.mathworks.com/matlabcentral/profile/authors/5981837-brett-goodwintag:nl.mathworks.com,2005:Question/1710502015-01-22T00:55:29Z2015-01-26T18:57:06Zhow can get the input delay and output delay of the narx nn?<p>I want to do system identification by using neural network. But how can i get the ID and FD of the narxnet by using auto correlation and cross correlation methods, which is described by Greg Heath. The method is shown as
2.Since training parameters should only depend on training data,
I use ztrn =zscore(ttrn,1), autocorrt = nncorr(ztrn,ztrn,Ntrn-1,'biased')
and find a 95% confidence level for significant auto AND
cross-correlations with abs values >= 0.14 by repeating 100
times and averaging:
a. Crosscorrelate ztrn with n = zscore(randn(1,Ntrn),1)
b. Correct the nncorr symmetry bug by concatenating:
crosscorrzn = [ crosscorrnz(1:Ntrn-1) crosscorrzn(Ntrn:end)]
c. Sort the absolute values and find the significance threshold
as the value at index floor( 0.95*(2*Ntrn-1))
But when i get the significance threshold, and then how can i get the ID and FD? Whether i should find the vaule of the unsorted crosscorrzn, which is equal to the value of the significance threshold. Is The index of the value delay? But i have a big training data, maybe 100000 symbles. So the value of the delay is maybe several thousands. But obviously it is wrong. therefore I want to know how to get the delay?</p><p>Thanks</p>Dongming Wanghttp://nl.mathworks.com/matlabcentral/profile/authors/6075005-dongming-wangtag:nl.mathworks.com,2005:Question/1720282015-01-26T18:38:57Z2015-01-26T18:38:57ZError in operspec function?<p>Anytime i run my model it returns the error in opersec (line 109)
update(op,false); It seem to be an update issue. Please can anyone provide a solution. thanks</p>tengarayhttp://nl.mathworks.com/matlabcentral/profile/authors/5448889-tengaraytag:nl.mathworks.com,2005:Question/1717392015-01-25T21:28:25Z2015-01-26T18:38:24ZHow to solve for pressure using the velocity field?<p>Hi,</p><p>I'm trying to solve for the pressure field on a 120x120 grid. I have the velocity field, and I have to use the Pressure Poisson Equation to solve for the pressure. The known boundary condition is P=Patm along the right edge of the grid. Using this I can get all the boundary conditions. I've created my coefficient matrix and I've tried so many different ways to solve the problems but I keep getting and error saying "Out of memory". I've tried solving by the easiest way which is Ax=b, x=A\b. Also by using reduced row echelon form. I'm now trying to solve using lower triangular matrix and the other an upper triangular matrix, but when I try using the function lu on MATLAB, again I get the same "Out of memory" message. Any comments or ideas are appreciated.</p><p>Thank you,</p><p>Orlando R.</p>Orlando Rojashttp://nl.mathworks.com/matlabcentral/profile/authors/6101887-orlando-rojastag:nl.mathworks.com,2005:Question/1719492015-01-26T13:44:53Z2015-01-26T18:37:56ZRead an image from an axes and write it in a listbox Matlab<p>I have a <b>list box</b> that return a list of images' names contained an a folder that i select. once i click on one of the names, i get the image displayed in an axes.</p><p>what i exactly want to do is when i click on a button called <b>Select Image</b>; the name of the image displayed in the <b>axes</b> will be written in a <b>second list box</b> that i have.</p><p>Does anyone have hints on how to do that?</p>alladinhttp://nl.mathworks.com/matlabcentral/profile/authors/5452474-alladintag:nl.mathworks.com,2005:Question/1720272015-01-26T18:35:31Z2015-01-26T18:35:31ZCan anyone of you help me with programming with Matlab using MATPOWER simulation package. I am new to this and I m looking for some guidance<p>I need to identify weak buses using PV curve method using matlab & matpower. Kindly guide me.</p>Shreehttp://nl.mathworks.com/matlabcentral/profile/authors/5654445-shreetag:nl.mathworks.com,2005:Question/1720252015-01-26T18:13:52Z2015-01-26T18:13:52Zsingle link inverted pendulum problem <p>hi everbody...My question is related to linmod..My inverted pendulum has a one link and one joint.When I would to linmod command ı obtained A=[0 1;14.7176 0] and B=[0 0]' instead of B=[0 1] and C=[0 0] again instead of c=[1 0]. what is my problem ı wait your suggestions thanks</p>ismail calikusuhttp://nl.mathworks.com/matlabcentral/profile/authors/6081228-ismail-calikusutag:nl.mathworks.com,2005:Question/1720202015-01-26T17:46:31Z2015-01-26T18:12:14Zformat of equation coefficients<p>Please, I have a part of a script transcript:</p><p>Btheta=miz*Htheta;
Btheta=subs(Btheta)
format shortEng
Btheta</p><p>The output doesn't present Btheta with the specified format:</p><p>Btheta =</p><p>(17802902220170337*sin(12*theta)*(107143972736275332039373393850264279320385678996161089849618843107/(294922159623673235357688878068056260995678776047895991812096000000000000000000000000000000000000000*r^12) - (191800976967353723011910915374755859375*r^12)/121976946326485916357963791565979648))/1180591620717411303424</p><p>How can I format the coeffients?</p><p>Thanks in advance.</p>Luizhttp://nl.mathworks.com/matlabcentral/profile/authors/5858229-luiztag:nl.mathworks.com,2005:Question/1720242015-01-26T18:05:01Z2015-01-26T18:05:20ZTrying to install Matlab but there is licensing issue<p>Hi. I tried to install Matlab on my personal laptop via download provided by Georgia Tech.
However, there is licensing issue saying that I already used up installation.
Since my previous laptop is not working (also, I uninstalled Matlab from the previous laptop), could you solve the licensing issue that I have?
I need Matlab for course work. Thank you.</p>Jae Ha Kunghttp://nl.mathworks.com/matlabcentral/profile/authors/4035077-jae-ha-kungtag:nl.mathworks.com,2005:Question/1712152015-01-22T20:07:10Z2015-01-26T17:57:21ZHow to look inside class based functions under Phased Array ToolBox?<p>Currently I am working on a DSP project. Here I am in a need to see inside a MATLAB function. I know many MATLAB built-in functions can be accessed via the command 'edit'. But the functions I need to see are class and object based functions. One of these functions is "Time Delay Beam Forming" under Phased Array Tool Box. Here an object called TimeDelayBeamformer is created with all necessary parameters and it is passed to the step function to perform the beamforming algorithm. I want to see the code. Is there anyway?</p>mohammad.monjilhttp://nl.mathworks.com/matlabcentral/profile/authors/3696199-mohammad-monjiltag:nl.mathworks.com,2005:Question/1714512015-01-24T20:36:30Z2015-01-26T17:56:32ZMulti-Line Colors in 2014<p>In 2013 and earlier I could do this to compare multi-line plots:</p><pre> % make up some data
X1 = rand(5,3);
X2 = X1+rand(5,3)*0.1;
plot(X1); % draw dataset 1
hold on;
plot(X2,':'); % compare with corresponding dataset 2
hold off;</pre><p>This is broken in matlab 2014: the second set of lines colours don't match up with the first set.</p><p>I guess this is because the axes keep track of the colororder index when hold is on.</p><p>How can I reset the colororder index so that subsequent plots restart with color 1, as in previous matlabs? I'd really rather not have to go through a for loop to draw each of the lines!</p>Sanjay Manoharhttp://nl.mathworks.com/matlabcentral/profile/authors/1857735-sanjay-manohartag:nl.mathworks.com,2005:Question/1720222015-01-26T17:52:00Z2015-01-26T17:52:00ZMatlab hardware support package offline installation error<p>I am running matlab R2014a on windows 7. I am trying to install a directsound support package offline. I have gotten the compressed zip files from a mathworks technician. When I run the installer through matlab and select, "install from folder", after selecting the folder that the zip files are in and clicking next I get the following error,
"C:\Users\mstarkey\Documents\DS does not contain any support package files.</p><pre> Specify a folder or subfolder that contains support package files. These files use the following
naming convention:
[name]_[release]_[version].zip"</pre><p>When I select the folder with the zip files through the installert, the zip files do not appear in the folder. It looks as though the folder that contains the zip files is empty when viewed in the installer.</p><p>I've attached the folder that I am trying to access.</p>michaelhttp://nl.mathworks.com/matlabcentral/profile/authors/5379705-michaeltag:nl.mathworks.com,2005:Question/1717182015-01-25T16:52:34Z2015-01-26T17:51:42Zhow can write this in matlab ?<p>I want to make one M-file that finds a function P(x)=A*e^M*x, which can approximate a function that is given in tabular shape.</p>Kadri Qevanihttp://nl.mathworks.com/matlabcentral/profile/authors/6101150-kadri-qevanitag:nl.mathworks.com,2005:Question/1720212015-01-26T17:47:26Z2015-01-26T17:47:26ZSecond order differential equations numerically. <p>I'm trying to solve 2 second order diff equations numerically.
y1' '=y2-2y1 and y2' '=y1-2y2.</p><p>I'm new to matlab and I'm trying to solve it without the initial condition.
Is it possible? Is so how?</p><p>Thanks in advance.</p>Kaushik Srinivasaraghavanhttp://nl.mathworks.com/matlabcentral/profile/authors/5547249-kaushik-srinivasaraghavantag:nl.mathworks.com,2005:Question/915072013-06-12T06:59:00Z2015-01-26T17:45:26ZWhy does MATLAB take a long time to start up?<p>I have many files in my MATLAB startup directory and it takes a long time for MATLAB to startup. I would like MATLAB to start up faster.</p>MathWorks Support Teamhttp://nl.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:nl.mathworks.com,2005:Question/1720192015-01-26T17:43:00Z2015-01-26T17:43:00Zhow can write a crossover that the offspring has same ones and zeros like parents?<p>I want to write a crossover for binary Chromosome.</p><p>we have two parents that are have same ones and zeros for example we have:</p><p>p1=[1 1 0 1 1 0]</p><p>p2=[1 1 1 1 0 0]</p><p>we see that p1 and p2 have same ones and zeros...4 ones and 2 zeros ...so we want to have one offspring from these parant that has same zeros and ones like parants for this example 4 ones and 2 zeros:</p><p>off=[1 0 1 0 1 1]</p><p>it is an example of offspring...</p><p>our Chromosome is bigger than this</p><p>Is there any way???</p>sarahttp://nl.mathworks.com/matlabcentral/profile/authors/5590407-saratag:nl.mathworks.com,2005:Question/1720182015-01-26T17:42:48Z2015-01-26T17:42:48Zhow to apply haar dwt feature extraction for more than one image using for loops?<p>i can not implement feature extraction using haar dwt for more than one image and i need to store the result in matrix ..i need help please.</p>trifa sherkohttp://nl.mathworks.com/matlabcentral/profile/authors/6104965-trifa-sherkotag:nl.mathworks.com,2005:Question/1711402015-01-22T11:44:13Z2015-01-26T17:36:40ZHow to use a GUI to set the polynomial level for a graph after examining the data<p>Hi there - me again!</p><p>I'm trying to make my program more and more clever but keep falling down when not understanding how to enter variables into functions of Matlab that expect a certain order. My bit of code I've made nicely shows the graph I want to fit the curve to, but, when the user enters the polynomial level, I can't get fit() command to use it.</p><p>Any help appreciated! Should I be using a different command to fit()?</p><pre class="language-matlab">% Fit a polynomial to the data
prompt2={'Enter the level of polynomial to use):'};
% Create all text fields with the questions specified by variable prompt
box2title='Polynomial Selection';
% The main title of your input dialog interface.
answer2= inputdlg(prompt2,box2title);
[Width_fit, gof] = fit( v1,wdth, answer2, 'Normalize', 'on' );
</pre><p>It's exspecting things like 'poly5' rather than just 5.</p><p>Thanks</p><p>Vadim</p>Vadim Baines-Joneshttp://nl.mathworks.com/matlabcentral/profile/authors/4398921-vadim-baines-jonestag:nl.mathworks.com,2005:Question/821922013-07-16T09:22:36Z2015-01-26T17:36:17ZFind duplicated values in a row and rename<p>I have a data array (100:500), and for the first vector(1,:) I would like to find the duplicated string values(the data in each cell is an string). For the result duplicated stings found I want to concatenate '_2'...'_n' depending on the duplicates found. I have try with the unique and histc functions but since is a vector of strings I could not achieve a good result.</p><p>I would really appreciate some help,</p><p>Thanks in advance</p>Manuelhttp://nl.mathworks.com/matlabcentral/profile/authors/4411664-manueltag:nl.mathworks.com,2005:Question/1719962015-01-26T16:45:06Z2015-01-26T17:34:12ZFinding minimum value in a 2D Matrix with a region<p>I have a set of 18 matlab vectors(raw readings of current values) data put into a 2d matrix of B[ 18 * 16348].</p><p>I have found the indices and max value of each vector and stored in another vectors namely M( has max values of each row vector of B) and l (has indices of max of each row vector of B).
[M,l]=max(B,[],2)</p><p>Now i want to find the least value of each row vector before this max value by looking backwards.
This would give me the difference between max curretn and the least current before.</p><p>I wrote a loop to look backwards and check for the least value and its indices. Apparently it does not work.</p><p>Could someone help ? Below is what i am trying.</p><pre class="language-matlab">o=l;
for i=1:18
while o(i)>0
if( B(i,o(i))>B(i,o(i)-1))
o(i)=o(i)-1;
else
display(o(i));
display(B(i,o(i)));
break;
end;
break;
end;
end;
</pre>Vittal Raohttp://nl.mathworks.com/matlabcentral/profile/authors/6104875-vittal-raotag:nl.mathworks.com,2005:Question/1713172015-01-23T13:57:33Z2015-01-26T17:25:47ZNetCDF file grid box extraction<p>I'm new to Matlab programming (usually use IDL) but I've been tasked with extracting meteorological data from netcdf files at specific gridsquares. I've looked at the structure of the file with ncread but my problem is that the netcdf is on a 193x by 130y grid that does not match any global grid. The gridpoint I'm looking for is at: lat 28.046, lon 86.902 in decimal degrees. How do I find where this is in the netcdf file?</p><p>An example of one of the netcdf files (test.nc) can be found here: https://drive.google.com/folderview?id=0B-amO6HuYM_yfjhFT3djOXF5dmhwaWc5b3Q4cXZoVkhMVFdJeU8xZ20tZXVpcXZTdzlVTEU&usp=sharing</p><p>Thanks</p>James Douglashttp://nl.mathworks.com/matlabcentral/profile/authors/6095462-james-douglastag:nl.mathworks.com,2005:Question/1719912015-01-26T16:13:37Z2015-01-26T17:25:35ZHow to convert 2 byte data to integer?<p>I have a two byte data (unsigned) as array.</p><p>e.g. x=[255 67]</p><p>I read the data from a sensor giving a stream of byte data (unsigned 0 to 255). From them I select corresponding two-byte of data set for necessary parameter calculation.</p><p>I want to convert this into an Integer value or a double value to do real mathematic calculations.</p><p>I tried with.</p><p>x=uint8([1 0])
y=typecast(x,'uint32') % but this gives an error.</p><p>if I use:
x=uint16([255 67])
y=typecast(x,'uint32')</p><p>% answer is</p><p>4391167</p><p>I don't how to check the answer is correct or not. Or the conversion syntax is correct?</p><p>Can anyone give me the code for correct 2-byte data conversion to integer..!</p>Tharindu Weerakoonhttp://nl.mathworks.com/matlabcentral/profile/authors/2598017-tharindu-weerakoontag:nl.mathworks.com,2005:Question/1717472015-01-25T23:33:25Z2015-01-26T17:16:37ZDerivatives of Cost Function for Minimizing<p>Hi,
I have this Cost Function H = 1/(deltaX)^2 [(A2 - A1)^2 + (A3 - A2)^2 + (A4 - A3)^2]
I'd like to minimize this cost function by forming the derivatives of our function's variable.
So here we have:</p><pre class="language-matlab">dH/dA1 = 2/(deltaX)^2 * ( - A2 + A1)
dH/dA2 = 2/(deltaX)^2 * (-A1 + 2A2 - A3)
dH/dA3 = 2/(deltaX)^2 * (-A2 + 2A3 - A4)
dH/dA4 = 2/(deltaX)^2 * (A4 - A3)
</pre><p>I need to write MATLAB code for above example.
I thank you If someone help me in this regards,</p><p>Best Regards,</p>ehsan http://nl.mathworks.com/matlabcentral/profile/authors/4483511-ehsantag:nl.mathworks.com,2005:Question/1709972015-01-21T17:17:15Z2015-01-26T17:12:17ZHow to convert step varying signal into linear signal(gradual rise and fall)><p>How to convert step varying signal into linear signal(gradual rise and fall)>
If any Simulink block available for this please reply the answers
If any other suggestions also welcome to convert step varying signal into linear signal in MATLAB(simulink)
Thanks in Advance</p>srinivas ramhttp://nl.mathworks.com/matlabcentral/profile/authors/3968352-srinivas-ramtag:nl.mathworks.com,2005:Question/1719582015-01-26T14:46:27Z2015-01-26T17:06:53ZPlot questions (variables at legend, labeling a marker)<p>hi , so i got two questions. i made a function to find an intersection between two lines (y=x+c) and then plots the lines. Now i have two questions, 1)how do i make the leggend accept the input variables to display.
2) how do i label the intersection point on the plot itself?</p><pre class="language-matlab">function p=inters(v1,v2) %v1,v2 are lines inputed as vectors i.e v1=[2 -1] v2=[-3,1] (y=2x-1,y=-3x+1)
xt=v1(1)-(v2(1));
c=v1(2)-(v2(2));
x0=(-c)/xt;
y0=v1(1)*x0+v1(2);
p=[x0,y0];
x=x0-5:x0+5;
xmarkers=x0;
ymarkers=y0;
plot(x,polyval(v1,x),'b',xmarkers,ymarkers,'b*')
hold
plot(x,polyval(v2,x),'g')
</pre><p>i need the legend to change depending on the input to the fuction v1 and v2 so me typing legend y=2x-1 wont work...</p>Alexhttp://nl.mathworks.com/matlabcentral/profile/authors/5950574-alextag:nl.mathworks.com,2005:Question/1719952015-01-26T16:43:13Z2015-01-26T16:43:13ZWhy am I getting redundant legend (group) icon colors when utilizing the gscatter command?<p>Hi. I’m attempting to color code the legend (group) entries in a group scatter plot using the following code:</p><pre class="language-matlab">% Clear out all workspace variables and the command window
clear all;
clc;
</pre><pre class="language-matlab">% Set values for OATTs and IDs
OATT = [8;10;12;14;16;18;20];
ID = [1;2;5;6;7;1;8];
</pre><pre class="language-matlab">% Preallocate LegCol and color
LegCol = cell(1, size(ID, 1));
color = cell(1, size(ID, 1));
</pre><pre class="language-matlab">% Setup cases for legend
for idx = 1:size(ID, 1)
switch ID(idx)
case 1
LegCol{idx} = 'Wild-1';
color{idx} = [1 0 0]; % red
case 2
LegCol{idx} = 'Jets-2';
color{idx} = [0 1 0]; % green
case 3
LegCol{idx} = 'Kings-3';
color{idx} = [0 1 1]; % cyan
case 4
LegCol{idx} = 'Sharks-4';
color{idx} = [1 0 1]; % magenta
case 5
LegCol{idx} = 'Ducks-5';
color{idx} = [1 1 0]; % yellow
case 6
LegCol{idx} = 'Coyotes-6';
color{idx} = [0 0 0]; % black
case 7
LegCol{idx} = 'Canucks-7';
color{idx} = [0 0 1]; % blue
case 8
LegCol{idx} = 'Blackhawks-8';
color{idx} = [0.8 0.8 0.8]; % grey
case 9
LegCol{idx} = 'Blues-9';
color{idx} = [1 0.55 0]; % orange
case 10
LegCol{idx} = 'Predators-10';
color{idx} = [0.58 0 0.83]; % violet
</pre><pre> end</pre><pre class="language-matlab">end
</pre><pre class="language-matlab">% Transpode LegCol and color data for legend use
Legend_Nomenclature = transpose(LegCol);
Color_Nomenclature = transpose(color);
New_Colors = cell2mat(Color_Nomenclature);
</pre><pre class="language-matlab">% Find unique elements of ID and use the returned index
% vector n as the y-axis value in the gscatter plot
[~, m, n] = unique(ID);
ID_Index = n;
</pre><pre class="language-matlab">figure('Name', 'Gscatter Test');
h = gscatter(OATT, ID_Index, Legend_Nomenclature, New_Colors, 'o', 15, 'on');
for n = 1:length(h)
set(h(n), 'MarkerFaceColor', New_Colors(n, :));
end
</pre><p>At this time, I have to apologize for the lack of an image as I’m unable to embed it in this question.</p><p>However, when I run the above code, the group scatter plot is created - as expected - with a single exception. For unknown reasons the last group of data (with ID = 8) shows up as a red dot on the plot and within the legend. It should in fact be grey.</p><p>What could be the cause of this?</p>Bradhttp://nl.mathworks.com/matlabcentral/profile/authors/118691-bradtag:nl.mathworks.com,2005:Question/1713532015-01-23T21:07:32Z2015-01-26T16:41:00ZConstraining Dependent Variables in ga Optimization<p>Hi,</p><p>I am trying to constrain my optimization for min f(x) by restricting the range allowed for a dependent variable h(x). I am using a the ga optimizer from the Optimization Toolbox. Do I need to write a penalty or barrier function into by objective function, or is there another simpler way that I can apply the constraint? I tried using the nonlcon input in the ga function, however have been unable to get it to converge. The documentation suggests that nonlcon can only take x (independent variable vector) as an input and so I think that reading in dependent variables may be a misuse of the function.</p><p>Please help! Any guidance would be greatly appreciated.</p>dpud12http://nl.mathworks.com/matlabcentral/profile/authors/4441189-dpud12tag:nl.mathworks.com,2005:Question/1589642014-10-17T06:27:54Z2015-01-26T16:39:51Zhow can remove the object that has the maximum distance from center of image?<p>if we have some objects in a binary image how can remove the object that has the maximum distance from center of image?
for example if this is my image:</p><img src = "/matlabcentral/answers/uploaded_files/19563/gg.jpg"><p>how can I obtain this image as result:</p><img src = "/matlabcentral/answers/uploaded_files/19564/gg2.jpg"><p>thanks</p>sarahttp://nl.mathworks.com/matlabcentral/profile/authors/5590407-saratag:nl.mathworks.com,2005:Question/1719942015-01-26T16:39:23Z2015-01-26T16:39:23ZHow to change contourf facealpha in 2014b ?<p>My current code grabs the children and changes their facealpha, but this no longer works in 2014b. I see I can dig down into "FacePrims" in the contourf handle, but I don't see alpha in there. Please avoid file exchange solutions if possible since I'm not working on a networked machine.</p>Chuck37http://nl.mathworks.com/matlabcentral/profile/authors/2235717-chuck37tag:nl.mathworks.com,2005:Question/1719802015-01-26T15:34:11Z2015-01-26T16:35:55ZHow to pass the output of a function to another function simultaneously?<p>I have 2 columns, first one's outlet is the inlet of the 2nd one. To run the 2nd column, I need to pass first one's output <b>at any time</b> to 2nd one. So how can I call column 1 function at any time
in column 2 function?</p><p>I would appreciate if anyone could help me out.</p>Naeimehhttp://nl.mathworks.com/matlabcentral/profile/authors/5482676-naeimehtag:nl.mathworks.com,2005:Question/1406982014-07-07T09:15:47Z2015-01-26T16:34:31ZI need to solve an equation, very similar to algebraic Riccati equation. I have tried to use the function 'care', but it returns error.<p>Hello everyone:</p><p>The equation I want to solve is A'X + XA + XBB'X + Q = 0 (Q>0 is a symmetric matrix), I want to get a symmetric matrix X>0.</p><p>It's very similar to the algebraic Riccati equation: A'X + XA - XBB'X + Q = 0, but the third part of my equation has a positive sign.</p><p>I have tried to use the function 'care', and set R=-eye(n): care(A,B,Q,R), the matlab returns me:
Unable to solve the specified Riccati equation because the Hamiltonian spectrum is too close to the imaginary axis.</p><p>I really want to know how to solve it. Maybe use other methods.</p><p>Thanks all.</p>Xinhttp://nl.mathworks.com/matlabcentral/profile/authors/3424971-xintag:nl.mathworks.com,2005:Question/1712662015-01-23T06:55:15Z2015-01-26T16:34:16ZSolving a nonlinear equation of two unknowns (a matrix and a vector) using fsolve in matlab?<p>I am solving a nonlinear equation in matlab using fsolve. The equation is W(BKhQ)exp(W(BKhQ)+Ah)−BKh=0. Where W is the LambertW function. Also A, B, & h are known and Q & K is to be determined. A & Q are matrices of 2*2. h is a scalar and B is a vector of 2*1 and K is a vector of 1*2. Any suggestions how to solve this in matlab using fsolve?</p>Niraj Choudharyhttp://nl.mathworks.com/matlabcentral/profile/authors/6094629-niraj-choudharytag:nl.mathworks.com,2005:Question/1709752015-01-21T14:37:49Z2015-01-26T16:22:47Zfinding number of pixels inside each circle<p>i am drawing circles of different radius on a jpg image. how to find the number of pixels in each circle. i have to compare the pixel distribution ratio in each circle</p>Dhandapani.Shttp://nl.mathworks.com/matlabcentral/profile/authors/4385382-dhandapani-stag:nl.mathworks.com,2005:Question/1719922015-01-26T16:15:47Z2015-01-26T16:15:47Zcontinuous feedback as filter applied to video<p>I am looking to use a value from my EEG recording (FFT applied to 500ms data segments, within a particular frequency band) to apply a grayscale filter to a video file in real time (the changing colour of the video acting as feedback to the individual having their EEG activity recorded). Does anyone have an idea of the best way to accomplish this? Thanks so much*</p>Chrishttp://nl.mathworks.com/matlabcentral/profile/authors/5659888-chris