http://www.mathworks.nl/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2014-09-15T09:28:39Ztag:www.mathworks.nl,2005:Question/1545402014-09-12T15:35:07Z2014-09-15T09:28:39ZRun code on multiple files within a directory?<p>Hi, hoping someone can help.</p><p>I have code that when run within a chosen directory, pops up a dialog box to choose file, to open through uigetfile and it runs through the code and outputs what I need to a .txt file and saves within the same directory. This is only for 1 file though, what I would like to do is for this to run through all the files in a directory in an automated fashion. I have tried a few things but I really can't get this to work and it seems to be due to how I'm using xlsread at the start.</p><p>I am using the following to read the data from the file:</p><pre class="language-matlab">[num text raw] = xlsread(uigetfile('*.extension'));
</pre><p>This allows me to easily use things like this to read off various values from headers etc I need:</p><pre class="language-matlab">date = num(3:2);
fileName = text(14:56);
</pre><p>I obviously don't want uigetfile popping up for every file to open but when I remove this I get errors complaining that xlsread can't use wildcards etc.</p><p>How can I get it so that my code cycles through all the files, runs my code then stops? I think it's something along these lines (Pseudocode):</p><pre class="language-matlab">% Get directory name
% get filename
% get number of relevant files within directory
% for i=1:number of relevant files
% run my code
% end
</pre><p>I just can't quite get it. Can someone help?</p>Ross/matlabcentral/answers/contributors/4283294-rosstag:www.mathworks.nl,2005:Question/1543962014-09-11T13:59:06Z2014-09-15T09:26:37ZHow to dot I use lsqcurvefit and now get the Optimization terminated error?<p>Hi I haven't used lsqcurvefit before and I can't get it to work.</p><p>As a test I thought I would generate a curve from the equation I would like to fit and then try to fit that curve and see if I can get back to the parameter values I initially put in.</p><p>But I get the following error</p><p>Optimization terminated: first-order optimality less than OPTIONS.TolFun,
and no negative/zero curvature detected in trust region model.</p><p>Here's my code</p><p>% generate dummy data from same equation with values a = [1 1 0.7]</p><pre> T = linspace(0.2,2,100);
a = [1 1 0.7];</pre><pre> for n = 1 : length(T)
% This is the equation I will apply the fit to
r(n) = (2* sqrt(a(3)))/ sqrt(a(1) + 3* a(3)* (2*pi/T(n)));
end
xdata = T';
ydata =r';
%Now I attempt to fit using lsqcurvefit - I would hope to get a = 1 1 0.7
%as above
predicted = @(a,xdata) (2.* sqrt(a(3))*ones(length(T),1)) ./ sqrt(a(1)*ones(length(T),1)+ 3* a(2)* (2*pi*ones(length(T),1)./xdata));
a0 = [1;1;0.6];
[ahat,resnorm,residual,exitflag,output,lambda,jacobian] =...
lsqcurvefit(predicted,a0,xdata,ydat)</pre><p>Any help much appreciated</p>Eddy/matlabcentral/answers/contributors/5186487-eddytag:www.mathworks.nl,2005:Question/1548362014-09-15T02:48:41Z2014-09-15T09:21:47ZUsing Visual C++ attached to Matlab session to debug mex function but local variables are wrong.<p>When I attached the Visual C++ 2010 Express to R2011b and then set a breakpoint inside the source for a complied mex function I expected the locals window to show values of variables defined in the function scope. Some are there but wrong and others are missing - like a variable defined by "int function_id;" for example. This is the first time I have tried this so I assume I am missing some large concept.
It seems like it should work. What do I need to do or need to understand?
The compiler selected by mex -setup is the Visual C++ express.</p>Eric nestler/matlabcentral/answers/contributors/128124-eric-nestlertag:www.mathworks.nl,2005:Question/1548562014-09-15T09:20:45Z2014-09-15T09:20:45Zdatestr datenum problem with year conversion.<p>Hello I have the following issue,</p><p>I am pulling out data from a Quandl, I get the following the set :</p><p>The syntax to pull out is the following :</p><pre> Quandl.get('USTREASURY/YIELD', 'trim_start', '1990-01-02', 'trim_end', '2014-09-12', 'authcode', 'jtwf2XzCdzxhAKrXxNkm')</pre><p>Time Series Collection Object: USTREASURY/YIELD</p><p>Time vector characteristics</p><pre> Start date 02-Jan-1990 00:00:00
End date 12-Sep-2014 00:00:00</pre><p>Member Time Series Objects:</p><pre> x1Mo
x3Mo
x6Mo
x1Yr
x2Yr
x3Yr
x5Yr
x7Yr
x10Yr
x20Yr
x30Yr</pre><p>Say this set is called YC.</p><p>By typing YC.Time or YC.x1Mo.Time, I get the datenum but it allocated the start date which is 02-Jan-1990 00:00:00 as 0 then increment till the end date which is 9019.( 9 sept 2014)</p><p>See a sample here</p><p>0
1
2
3
6
7
8
9
10
14
15
16
17</p><p>When i make a datestr of this matrix, I get a straight integer increment for year 1990, to now, that is 1990 is taken as 0 and ends as 0024, which stands for 2014.</p><p>See Sample</p><p>00/01/0000 00:00:00
01/01/0000 00:00:00
02/01/0000 00:00:00
03/01/0000 00:00:00
06/01/0000 00:00:00
07/01/0000 00:00:00
08/01/0000 00:00:00
09/01/0000 00:00:00
10/01/0000 00:00:00
14/01/0000 00:00:00
15/01/0000 00:00:00
16/01/0000 00:00:00
17/01/0000 00:00:00</p><p>I have tried also things like this datestr(YC.Time,'dd/mm/yyyy HH:MM:SS') but does not work.</p><p>I have the impression, the year is non existent in the time vector and it has only month and date and allocates an incremental year number till now.</p><p>Do you know how I can make this time vector starts from 1990 and continue till now.</p><p>I can code something to make this work in a loop, but I fear there is a much easier way to do that using may be pivot year, which I cannot seem to find.</p><p>Thanks you very much.</p><p>D.</p>Davin/matlabcentral/answers/contributors/5475703-davintag:www.mathworks.nl,2005:Question/1548552014-09-15T09:18:47Z2014-09-15T09:18:47ZWhy is the design matrix different when using x2fx as opposed to the output of cordexch?<p>Dear all,</p><p>I have a problem where I am using a D-optimal interaction design with some categorical variables. However, I found it impossible to reconstruct the design matrix "X" from the predictor matrix "dCe" using the "x2fx" function if the number of tries in the "cordexch" function is more than 1. In terms of code, with an example:</p><pre class="language-matlab">[dCe, X1] = cordexch(2, 40, 'interaction', 'categorical', 1:2, 'levels', [3,3], 'tries', 100);
X2 = x2fx(dCe, 'interaction', 1:2);
</pre><p>Why is X1 ~= X2 ? The predictor matrix dCe is the same in both cases, but both functions come up with different design matrices... I found that using only 1 try gets the same output for both cases, but as soon as 'tries' > 1, the matrices differ...</p>Lukas Rohr/matlabcentral/answers/contributors/2743067-lukas-rohrtag:www.mathworks.nl,2005:Question/1311732014-05-26T13:01:08Z2014-09-15T09:16:00ZHow print a GUI to pdf with good quality?<p>I want to print a GUI to pdf. I use the following code:</p><pre class="language-matlab">print(f, '-dpdf', 'Filename.pdf')
</pre><p>where f is the handle of the GUI. However the quality of the pdf is not satisfying. All the texts are a bit blurred. What can I do to improve the quality?</p>Roger Wohlwend/matlabcentral/answers/contributors/1131237-roger-wohlwendtag:www.mathworks.nl,2005:Question/1541322014-09-09T10:56:17Z2014-09-15T09:03:47ZWhy mafdr works only for one threshold?<p>hi!
i have an array of p-values and i put him in mafdr() and it works fine.
when i try to threshold this array of p-values and put the new array(array with values less than a threshold) in mafdr i get this error</p><p>??? Error using ==> mtimes
Inner matrix dimensions must agree.</p><p>Error in ==> mafdr>storeyFDR at 239
fdr = pi0 * v./r;</p><p>Error in ==> mafdr at 190
[fdr, q, pi0_all, pi0, cs, rs] = storeyFDR(p, lambda, bootflag);</p><p>the only threshold that works for me is 0.05!!!
i use matlab 2010a...whats wrong...?</p>hmmaros/matlabcentral/answers/contributors/3896431-hmmarostag:www.mathworks.nl,2005:Question/1534012014-09-04T12:54:56Z2014-09-15T09:03:42ZAssignin table to the workspace and order of execution. <p>Hello,</p><p>I have a question on this command assignin. I am coding to filter some monthly data into quarterly, during this process, I have created some intermediary tables, using assignin, but the last statement of my code, will horzcat a date column and a data column, bearing in mind that the i pushed out the date and data array with assignin on the base workspace. But when the code comes to the horzcat, the tables which are needed to do the horzcat are not created yet so i have an error as follows :</p><p>Undefined function or variable 'datesQ'.</p><p>Error in GlobalMacroGui>uipanel13_SelectionChangeFcn (line 722)
test = horzcat(datesQ,dataQ)</p><p>Error in gui_mainfcn (line 96)
feval(varargin{:});</p><p>Error in GlobalMacroGui (line 42)
gui_mainfcn(gui_State, varargin{:});</p><p>Error in
@(hObject,eventdata)GlobalMacroGui('uipanel13_SelectionChangeFcn',get(hObject,'SelectedObject'),eventdata,guidata(get(hObject,'SelectedObject')))</p><p>Error in hgfeval (line 63)
feval(fcn{1},varargin{:},fcn{2:end});</p><p>Error in uitools.uibuttongroup/childAddedCbk>manageButtons (line 79)
hgfeval(cbk, source, evdata);</p><p>Error while evaluating uicontrol Callback</p><p>I do the get the creation of the tables only after this...</p><p>Is there another way to create these tables so that i can concatenate the 2 arrays. Or is there a way to wait until the creation of the table and then execute the cat...</p><p>I would much appreciate any help.</p><p>Thank u</p><p>D</p>Davin/matlabcentral/answers/contributors/5475703-davintag:www.mathworks.nl,2005:Question/1532402014-09-03T07:19:55Z2014-09-15T08:52:20ZSerial Communication involving terminator in MATLAB<p>Hi
I am trying to read data from serial port in MATLAB at 115200 baudrate.Serial data has terminator character and i want to read data untill first terminator is reached. Then read data again untill next terminator character and so on.I have tried several function like fread, fgetl, fgets, fscanf etc. But on most occasions when i read data my last character is not terminator but some other character. When i used fgets and fgetl only three characters were read. please suggest solutions.</p>Muhammad Hammad/matlabcentral/answers/contributors/4106075-muhammad-hammadtag:www.mathworks.nl,2005:Question/407512012-06-09T17:45:04Z2014-09-15T08:50:00Zislanding detection<p>i want a simulink model for detection of islanding at medium voltage medium or at least i want a model for medium voltage system while connecting the destributed generator
thanks in advance</p>mostafa/matlabcentral/answers/contributors/3525985-mostafatag:www.mathworks.nl,2005:Question/1546052014-09-13T06:41:11Z2014-09-15T07:56:02Zhow to convert sym to double?<p>hello, i have a system of n equations which i need to differentiate, so the variables must be symbolic variables, and i stored those equations in an array, my problem is that i want to solve the system using the fsolve but i am not able to convert my symbolic variables to double, so let my code be like that:</p><pre class="language-matlab">function dif = mydifffunction2 (~)
n=input('n=');
h=3;
dif=sym(zeros(1,n));
F=0;
x=sym(zeros(1,n));
for k=1:n
x(k) = sym(sprintf('x%d',k));
end
for i=1:n
D= 0.5;
% V=0;
% b=0;
for j=1:n
if (mod(j,2)==0)
D = D + cos(h*x(j));
else
D = D - cos(h*x(j));
end
end
D=(2*sqrt(2)/(pi*h))*abs(D);
F = F + 1/h*(D^2)
h=h+2;
end
for j=1:n
dif(j)=diff(F,x(j),1);
end
</pre><p>how can i convert each of these variables to double???
Thanks in advance.</p>Physiker192/matlabcentral/answers/contributors/5511956-physiker192tag:www.mathworks.nl,2005:Question/1548452014-09-15T06:46:42Z2014-09-15T07:48:22ZHow to delete selective part of image?<p>I am working on a project part of which requires removal of certain part of the image can anyone please help me with that ????
The input image is a front view of a face(does not contain any disguise)I want to delete its eyes. Is that possible??</p>Madhura Bombatkar/matlabcentral/answers/contributors/5036147-madhura-bombatkartag:www.mathworks.nl,2005:Question/1548512014-09-15T07:14:59Z2014-09-15T07:45:45ZHow 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/5642314-moon-suntag:www.mathworks.nl,2005:Question/623692013-02-05T18:21:24Z2014-09-15T07:45:25ZHow do I read data from a binary table in matlab using fitsread?<p>I am having trouble getting matlab to reconstruct (or uncompress) a FITS image that was compressed in Matlab using fits.imgCompress(infptr,outfptr). Below is the test code that I have been playing with. First I read in a FITS file that was created in Matlab, then I compress the image with a RICE compression algorithm and write the file out to disk. Then I read the compressed file back in with the hope that I can recreate the original file, but I am having trouble getting the data back out in a usable format.</p><p>I tried data = fitsread('file', 'binarytable'), but data only contains a 1 x 2 array of data and not the entire image as expected.</p><p>I tried colData = matlab.io.fits.readCol(fptr,1); colData seems to have the information that I am after, but I don't know what to do with it.</p><p>When I read the same files into Python using the pyfits module, I can reconstruct the original data, so I know the file is not corrupt.</p><p>I don't know how to attach the FITS file to this post.</p><pre class="language-matlab">filetoread = 'C:\LocalData\000005GEOST156328.1024.fit';
filetowrite = 'C:\LocalData\000005GEOST156328.1024.hcomp.fit';
infptr = matlab.io.fits.openFile(filetoread);
outfptr = matlab.io.fits.createFile(filetowrite);
matlab.io.fits.setCompressionType(outfptr,'RICE');
% matlab.io.fits.setHCompScale(outfptr, 2.5);
matlab.io.fits.imgCompress(infptr,outfptr);
matlab.io.fits.closeFile(infptr);
matlab.io.fits.closeFile(outfptr);
</pre><pre class="language-matlab">info = fitsinfo(filetowrite);
fptr = matlab.io.fits.openFile(filetowrite,'READONLY');
cleaner = onCleanup(@() matlab.io.fits.closeFile(fptr));
matlab.io.fits.movAbsHDU(fptr,2);
ncols = matlab.io.fits.getNumCols(fptr);
nrows = matlab.io.fits.getNumRows(fptr);
[dtype,repeat,width] = matlab.io.fits.getEqColType(fptr,1);
[NROWS,TTYPE,TFORM,TUNIT,EXTNAME,PCOUNT] = matlab.io.fits.readBTblHdr(fptr);
colData = matlab.io.fits.readCol(fptr,1);
matlab.io.fits.closeFile(fptr);
data = fitsread(filetowrite,'binarytable','Info',info);
</pre>Aldo Apponi/matlabcentral/answers/contributors/1414932-aldo-apponitag:www.mathworks.nl,2005:Question/1548542014-09-15T07:41:27Z2014-09-15T07:41:27Zproblem converting a function<p>Hello, i have a system of symbolic equation which i need to solve, so i tried to solve it using this function:
my_dif = mydifffunction2;
g = matlabFunction(my_dif);
h = my_vectorize(g);
fsolve(h,[0.2,0.3,0.4,0.5])</p><p>where my diff function is an array of symbolic variables
and my_vectorize converts it usinf num2cell
the problem is i had the same value stored in an array as:
0.2672 0.2672 0.2672 0.4189
which doesn't make any sense, can anybody help??
thanks in advance</p>Physiker192/matlabcentral/answers/contributors/5511956-physiker192tag:www.mathworks.nl,2005:Question/1548522014-09-15T07:18:35Z2014-09-15T07:41:20ZTrying to create exe from GUI..<p>https://www.youtube.com/watch?v=Ke599czEmxU</p><p>I have seen this video and created exe from GUI..
when i try to install it after creating, it shows message in command prompt :</p><p>Replace All(A), None(n), etc..</p><p>Whatever i do, Installation being cancelled.</p><p>What may be the problem.</p><p>I have created .exe file from Windows operating system, and tried created exe in both XP and windows, but not works..</p>Nimisha/matlabcentral/answers/contributors/5376957-nimishatag:www.mathworks.nl,2005:Question/1548532014-09-15T07:35:42Z2014-09-15T07:35:42ZHow do I give a compiled MATLAB script permission to operate on server folders?<p>Hi everybody,</p><p>I've got my MATLAB scripts which works totally fine as I run the script itself. As soon as I compile it the .exe seems not to have access on the servers folders where the script is ran from.</p><pre class="language-matlab">path=fullfile(path,'Results');
filepath0=fullfile(path,'*.txt');
fprintf('%s \n',path);
</pre><pre class="language-matlab">%% Data
</pre><pre class="language-matlab">%Open data
fprintf('read files \n');
files=dir(filepath0);
fprintf('list files \n');
fprintf(files.name);
fprintf('listed files \n');
</pre><p>When I run the .exe file in the same folder structure (for the relative paths) but on a local drive it work fine (path gets printed, files get listed). When I run the .exe on the server (the user has access but isn't admin) the path gets printed correctly but there is an error with printing "fprintf(files.name);" so it seems like the variable files is completely empty. I think there must be a problem with the permissions. As I say when I run it as the normal script from the very same server folder It work perfectly.
How do I tell my exe file that the current user can access those network folders an read out my files?</p><p>Thank you a lot!</p><p>Benjamin</p>Benjamin/matlabcentral/answers/contributors/3292073-benjamintag:www.mathworks.nl,2005:Question/356472012-04-16T17:54:36Z2014-09-15T07:27:33ZParallel Code<p>Hi</p><p>Can I run this code in parallel?</p><p>A1=F(A1,B1)</p><p>A2=F(A2,B2)</p><p>F is a function, A1 B1 are unrelated to A2 B2</p><p>How can I do this ? ( now it runs one after the other)</p><p>Thanks</p><p>Shani</p>Shani Gal/matlabcentral/answers/contributors/1077966-shani-galtag:www.mathworks.nl,2005:Question/1547952014-09-14T17:15:42Z2014-09-15T07:26:02Zmeaning of pc in princomp of matlab<p>Hi,</p><p>I am doing PCA using Matlab. In theory i studied that, the principal components are the eigen vector of the covarince matrix. I run the command <i>(W,pc)=princomp(x)</i> to do the same. But i did not understand what is pc and W here. I checked out that, pc here is not the eigen vector of the covariance matrix of the x. Can you pls explain what is pc here and how mathematically it could be found?</p><p>Thanks in advance :)</p>shambhu/matlabcentral/answers/contributors/5492753-shambhutag:www.mathworks.nl,2005:Question/1548502014-09-15T07:14:09Z2014-09-15T07:14:09ZHow 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/5642314-moon-suntag:www.mathworks.nl,2005:Question/1548492014-09-15T07:10:07Z2014-09-15T07:10:07ZHow to solve OZ equation<p>Hello everyone</p><p>I want to solve this general expression
where h, c, U are 2x2 matrix with n values of each and a= 1, 2 and b = 1, 2</p><p>hab+1- Uab.*exp(hab-cab)</p><p>Can any one help me how to solve it</p><p>where my h matrix will be h11, h12, h21, h22
c matrix is c11, c12, c21, c22 and
U matrix is U11, U12, U21, U22</p><p>Thank you</p>Uday padidela/matlabcentral/answers/contributors/5407423-uday-padidelatag:www.mathworks.nl,2005:Question/1548442014-09-15T06:30:02Z2014-09-15T07:09:27ZNumber of Inputs of a function<p>Hi all,</p><p>I have a problem with choosing the Input of this function:</p><pre class="language-matlab">[Outputs]=function[In1,In2,In3,In4,..In7]
M=regress(In1,In2)
...
...
...
end
</pre><p>I want tobe able to choose</p><pre class="language-matlab">M=regress(In1,In2) or M=regress(In1,In3), M=regress(In1,In4) ,.....M=regress(In1,In7) or M=regress (In1, IN2 In3,..IN5);
</pre><p>or to ignore an inputs when it doesnot occured.</p><p>I hope my question is clear.</p><p>Thank you</p>Rica/matlabcentral/answers/contributors/3745942-ricatag:www.mathworks.nl,2005:Question/1548262014-09-15T00:38:26Z2014-09-15T07:08:57ZHaving issue after downloading tabular data from web.<p>After downloading a table of data from the web and converting the cells to double as I need to analyse these numbers, for some reason the is there are no digits before or after the decimal point it get converted to a whole number.</p><p>For example if "v" is the vector consisting of cells</p><pre class="language-matlab">if true
*v=
{'$ 47.21'
'$ .91'
'$ 14.11'
'$ 15'}*
% code
end
</pre><p>After using the following code:</p><pre class="language-matlab">if true
b1=regexp(v,'\d+(\.)?(\d+)?','match');
b(:,1)=str2double([b1{:}]);
% code
end
</pre><p>This is what i get:</p><p>b= [ 47.21 91 14.11 15]</p><p>instead of b= [ 47.21 0.91 14.11 15]</p><p>How do I go about fixing this, no matter what algorithm I use to fix 91 its gonna do the same to 15 as well.</p><p>Thanks,</p>Ron Aditya/matlabcentral/answers/contributors/4529545-ron-adityatag:www.mathworks.nl,2005:Question/1548482014-09-15T07:05:10Z2014-09-15T07:05:10ZHow can I acquire the label matrix after segmentation an image?<p>How can I acquire the label matrix after segmentation an image?</p>moon sun/matlabcentral/answers/contributors/5642314-moon-suntag:www.mathworks.nl,2005:Question/1379362014-06-27T12:05:36Z2014-09-15T07:03:54Zip camera connect to matlab<p>hi every body...i want to connect ip camera to matalb..i need to(snapshot) capture image from ip camera through matlab...i need code in matlab to used...
this ip camera datasheet: <a href = "http://www.dlink.com/-/media/Business_Products/DCS/DCS%25206010L/Datasheet/DCS_6010L_Datasheet_EN.pdf">d-link</a></p>primrose khaleed/matlabcentral/answers/contributors/5155066-primrose-khaleedtag:www.mathworks.nl,2005:Question/1543112014-09-10T20:18:57Z2014-09-15T07:02:01Z4-Port Scatter parameters to 2-Port Scatter Paremeters<p>Is it always customary to convert 4-Port S-Parameters to 2-Port S-Parameters and then plot Smith's chart ? Why ?</p>analogy/matlabcentral/answers/contributors/5624439-analogytag:www.mathworks.nl,2005:Question/1548472014-09-15T06:55:19Z2014-09-15T08:39:35ZHow can I change the order of lines using EXPORT_FIG for PDF export?<p>Hi everybody,</p><p>I've got a problem with Oliver's <a href = "http://www.mathworks.com/matlabcentral/fileexchange/23629-export-fig">EXPORT_LINK</a> function.
When I export my figure as PNG everything's fine (see attached). But actually I'd like to save it vectorized as PDF. And as you can see the outcome is completely different (especially the order of the lines).
So, the question is: Is there a way to fix this problem? I've already tried UISTACK but it seems to have no effect on the PDF export.</p><p>Regards,
Johannes</p><img src = "/matlabcentral/answers/uploaded_files/18156/PNG.png">Johannes/matlabcentral/answers/contributors/2899618-johannestag:www.mathworks.nl,2005:Question/1548412014-09-15T05:20:20Z2014-09-15T06:50:24ZHow 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/4847804-sherrysherrytag:www.mathworks.nl,2005:Question/1548462014-09-15T06:47:11Z2014-09-15T06:48:46ZHow to get polygon coordinates?<p>So far i have possibility to select polygon on image, but additionally it would be nice to have coordinates of chosen area.</p>Vladimir/matlabcentral/answers/contributors/5393599-vladimirtag:www.mathworks.nl,2005:Question/1548142014-09-14T21:33:27Z2014-09-15T06:39:36Zhow to import a lot of data files<p>hello
i want to import to matlab a lot of data files with one line to write on MatLab instead of that all line.</p><ul><li>load aae20100101dmin.min</li><li>load aae20100102dmin.min</li><li>load aae20100103dmin.min</li><li>load aae20100104dmin.min</li><li>load aae20100105dmin.min</li><li>load aae20100106dmin.min</li><li>load aae20100107dmin.min</li><li>load aae20100108dmin.min</li><li>load aae20100109dmin.min</li><li>load aae20100110dmin.min</li><li>load aae20100111dmin.min</li><li>load aae20100112dmin.min</li><li>load aae20100113dmin.min</li><li>load aae20100114dmin.min</li><li>load aae20100115dmin.min</li><li>load aae20100116dmin.min</li><li>load aae20100117dmin.min</li><li>load aae20100118dmin.min</li><li>load aae20100119dmin.min</li><li>load aae20100120dmin.min</li><li>load aae20100121dmin.min</li></ul>aliaa madbouly/matlabcentral/answers/contributors/3878507-aliaa-madboulytag:www.mathworks.nl,2005:Question/1545102014-09-12T11:50:41Z2014-09-15T06:33:48ZHow can I use elements of a vector for the '' for loop '' ?<p>I want to code some simple formulas for the ultimate strength calculation of ship panels. I have coded nested for loop in a function. Inner loop uses elements of a vector as loop boundary. But in this case, it gives some incorrect results. Related part of my code is attached. In my code N is a vector whose dimension is kx1. I have to use every single element of N vector as boundary for inner loop. Other vectors have been calculated previously.</p><p>Thank you so much in advance.</p><p>Best Regards.</p><p>Murat</p>ITU/matlabcentral/answers/contributors/4139076-itutag:www.mathworks.nl,2005:Question/1548372014-09-15T04:35:25Z2014-09-15T06:32:44Zwhy is my while loop only looping once?<p>f=@(x) (1/x)-37;</p><p>if f(a)>0 && f(b)>0 f(a)<0 && f(b)<0
error('does not bracket root')
end</p><p>ea=1000;
es=(.5 *10^(2-5)); %5 sig figs
while es < ea
root=(a+b)/2;
oldroot=root;
if f(root)>0 && f(a)>0 f(root)<0 && f(a)<0
a=root;
else
b=root;
end</p><pre> ea=abs(((root)-oldroot)/root)*100;</pre><p>end %second end because it is a function i just did not include</p><p>end</p>Brandon/matlabcentral/answers/contributors/4094986-brandontag:www.mathworks.nl,2005:Question/1548432014-09-15T06:09:04Z2014-09-15T06:09:04ZHow can i remove audio glitches <p>Hi
I'm new to this signal processing...
i dont know which to use either Sigmoid envelope or Hilbert functon..!
if we use Sigmoid envelop
(x) = 1 / (1 + e ^ (-x))
how does it do...?</p>Nandish/matlabcentral/answers/contributors/5580319-nandishtag:www.mathworks.nl,2005:Question/1548422014-09-15T06:04:32Z2014-09-15T06:04:32ZI am using a trainbr function to train a NN on 120X134 matrix. It trains very well even with three nodes in hidden layer but does not give satisfactory results on a test matrix. If this is a case of overfitting, how should I avoid it? <p>The network is being used to classify into 4 classes</p>Moon Inder/matlabcentral/answers/contributors/5605715-moon-indertag:www.mathworks.nl,2005:Question/1540882014-09-09T03:34:28Z2014-09-15T05:14:46ZProblem with mex setup for FORTRAN<p>I got a error message with</p><pre class="language-matlab">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/283520-durga-lal-shresthatag:www.mathworks.nl,2005:Question/1548402014-09-15T05:14:00Z2014-09-15T05:14:00ZWindow CE에서 Matlab Compiler Runtime이 지원 되는가요?<p>window CE 에서 MCRInstaller.exe 를 실행하여 MCR 설치후 GUI를 실행 시켰습니다.
하지만 mclmcr initialization failed 라는 에러가 뜨며 실행이 안되는데요.
혹시 window CE 용 MCRInstaller가 있을까요?</p>song Sangyeol/matlabcentral/answers/contributors/1780730-song-sangyeoltag:www.mathworks.nl,2005:Question/1544472014-09-12T00:20:59Z2014-09-15T04:45:18ZHow to write code for hankle and toeplitz matrix?<p>I have matrices like</p><pre class="language-matlab">F = [CA;CA^2;CA^3;CA^4;CA^5;CA^6;CA^7;CA^8;CA^9;CA^10]
</pre><p>and other matrix is</p><pre class="language-matlab">phi=[CB 0 0 0;
CAB CB 0 0;
CA^2B CAB CB 0;
CA^3B CA^2B CAB CB;
CA^4B CA^3B CA^2B CAB;
CA^5B CA^4B CA^3B CA^2B;
CA^6B CA^5B CA^4B CA^3B;
CA^7B CA^6B CA^5B CA^4B;
CA^8B CA^7B CA^6B CA^5B;
CA^9B CA^8B CA^7B CA^6B]
</pre><p>How can I do matlab coding for these matrices</p>baruch/matlabcentral/answers/contributors/5509718-baruchtag:www.mathworks.nl,2005:Question/1548392014-09-15T04:41:43Z2014-09-15T04:41:43Zhow to see the variable in VC ++6.0 with MATCOM?<p>I have installed the MATCOM4.5, and can see the tool bar in VC++6.0;
when the VC program is stopped at a breakpoint. I click the eyeglass button in the Visual MATCOM toolbar, and enter a Var into the Matrix Name box and click Reload, it shows “Error:cannot locate debugged process, add the global :unsigned int milbpr...”，
ask for your help , Thank you very much!</p>wang/matlabcentral/answers/contributors/5636567-wangtag:www.mathworks.nl,2005:Question/1548382014-09-15T04:40:03Z2014-09-15T04:40:03ZHow to obtain wavelet reconstructed image under command line?, how to get result in gray scale under command line?<p>I am trying to learn wavelet toolbox (R2010a version) for developing some m-functions for image (gray scale) segmentation. To start with, I was analysing an image using Graphical interface and command line to check whether I am getting identical results (to build confidence!). I used simple 'dwt2' command to extract coefficients and then 'idwt2'/'upcoef2' commands (as per instructions) for reconstruction. However, I am getting two completely different results. Please help me in finding out my mistakes.
Command line instructions used by me are:</p><pre> [cA1,cH1,cV1,cD1] = dwt2(I,'db4');
A1 = upcoef2('a',cA1,'db4',1);
H1 = upcoef2('h',cH1,'db4',1);
V1 = upcoef2('v',cV1,'db4',1);
D1 = upcoef2('d',cD1,'db4',1);</pre><p>OR</p><p>sx = size(I);
A1 = idwt2(cA1,[],[],[],'db4',sx);
H1 = idwt2([],cH1,[],[],'db4',sx);
V1 = idwt2([],[],cV1,[],'db4',sx);
D1 = idwt2([],[],[],cD1,'db4',sx);</p><p>For display:</p><p>subplot(2,2,1); image(wcodemat(A1,512));
title('Approximation A1')
subplot(2,2,2); image(wcodemat(H1,512));
title('Horizontal Detail H1')
subplot(2,2,3); image(wcodemat(V1,512));
title('Vertical Detail V1')
subplot(2,2,4); image(wcodemat(D1,512));
title('Diagonal Detail D1')</p><p>Further, how to get result in gray scale under command line?
Thanks a lot.</p>Badal/matlabcentral/answers/contributors/4525067-badaltag:www.mathworks.nl,2005:Question/1532312014-09-03T03:56:47Z2014-09-15T04:16:53ZHow can find area of the dent detected?<p>Hi,
i have already found the dent in the laminates but i need find the area of the dent</p><p>please help me on this</p>vijendra sn/matlabcentral/answers/contributors/5289535-vijendra-sntag:www.mathworks.nl,2005:Question/1542812014-09-10T14:55:52Z2014-09-15T04:06:52Zsynthesize PSD, scaling and units of ifft(X)<p>I want to recover a time signals from a given power spectral density, assuming a normal distribution of the original signal:</p><pre class="language-matlab">PSD; % [(m/s)^2/Hz] given spectrum
T = 60; % [s] length of original signal
dt = 0.005; % [s] time step of original signal
N = T/dt; % [-] number of samples
NFFT = 2^nextpow2(N); % [-] number of bins for FFT
fs = 1/dt; % [Hz] sampling frequency
ASD = sqrt(PSD); % [(m/s)/sqrt(Hz)] get amplitude spectrum
omega = 2*pi*rand(NFFT/2,1); % [rad] generate phase vector
Z = ASD.*exp(1i*omega); % create complex amplitude vector
Z = [0;Z;flipud(conj(Z))]; % extend to satisfy symmetry
Y = real(ifft(Z)); % inverse FFT
[PSDY,f] = pwelch(Y,[],[],NFFT,fs); % generate PSD from Y to compare
</pre><p>The results show a power spectrum several orders of magnitude lower than the original, but the shape matches very good. I guess there is something wrong with the units or there might be a scaling factor missing. I'm not sure about the units of the time signal after ifft, since the amplitude has [(m/s)/sqrt(Hz)].</p>Felipe/matlabcentral/answers/contributors/5622467-felipetag:www.mathworks.nl,2005:Question/1545732014-09-12T19:18:46Z2014-09-15T03:46:43ZProgrammatically create annotation with hyperlink<p>Hello,</p><p>I have a model in which I would like to include a hyperlink to an excel file that contains more information about the model. The model and excel file are contained within the same Simulink project however I would like to be able to share the project with someone else, but maintain that hyperlink regardless of where they put the project file.</p><p>In my project open script I am getting the root directory of the project using
ProjectRootDir = fileparts(mfilename('fullpath'));</p><p>and I know I can create an annotation programmatically using the methods described here: <a href = "http://www.mathworks.com/help/simulink/ug/create-an-annotation-programmatically.html">http://www.mathworks.com/help/simulink/ug/create-an-annotation-programmatically.html</a></p><p>But no where do I see a parameter to enable a hyperlink and create it using a Matlab variable. Is there another way to implement this?</p><p>Thanks!</p><p>Max</p>Maximilian/matlabcentral/answers/contributors/4513463-maximiliantag:www.mathworks.nl,2005:Question/1548052014-09-14T19:40:55Z2014-09-15T03:37:00Zhow we can imfill a thing that it is very similar to a hole but in fact it is not a hole?<p>how we can imfill a thing in an binary image that it is very similar to a hole but in fact it is not a hole?</p><img src = "/matlabcentral/answers/uploaded_files/18148/mu.jpg"><p>I attached a simple image that in the left side there is a thing that looks like a hole but it is not a hole</p>sara/matlabcentral/answers/contributors/5590407-saratag:www.mathworks.nl,2005:Question/1546312014-09-13T13:15:29Z2014-09-15T03:31:08Zparallel 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/4311650-rashmil-dahanayaketag:www.mathworks.nl,2005:Question/1548322014-09-15T02:06:17Z2014-09-15T03:16:34ZSimMechanics Mechanics Explorer does not render on one PC but not another<p>I'm using MatLab R2013b with Simscape & SimMechanics. When I open `sm_four_bar` on one PC (with GeForce GT 720), I could run the simulation, but the Mechanics Explorer shows nothing (I tried changing views but it didn't work). On another PC with integrated graphics, the animation shows properly. I wonder what is happening and how I could work around this issue?</p><img src = "/matlabcentral/answers/uploaded_files/18155/ScreenClip.png">Yin/matlabcentral/answers/contributors/5638104-yintag:www.mathworks.nl,2005:Question/1548282014-09-15T01:39:22Z2014-09-15T03:00:40Zi have a large matrix whose elements is 1 and 0; how to conver each row to decimal ,like bin2dec<p>i do it like this</p><pre class="language-matlab">if true
rownum = size(Qbinnum,1);
for i = 1:rownum
</pre><pre> cgroup(i)=bin2dec(num2str(Qbinnum(i,:)));
end
end</pre><p>as the matrix is big, so it takes a lot of seconds ,any way easier ,less time ways?</p>Roger/matlabcentral/answers/contributors/4198367-rogertag:www.mathworks.nl,2005:Question/1548342014-09-15T02:18:40Z2014-09-15T02:57:25ZWhy no APSK Modulation in matlab ? <p>Why no APSK Modulation in matlab ?
No blocks for APSK Modulators and demodulators like other modulation techniques QAM,PSK ,ASK .</p>Karim/matlabcentral/answers/contributors/1916562-karimtag:www.mathworks.nl,2005:Question/1548332014-09-15T02:10:06Z2014-09-15T02:52:33Zhow to get the index of the same element in a cell<pre class="language-matlab">if true
Qzonenum=unique(cgroup);
for i = 1:length(Qzonenum)
globidx=find(cgroup==Qzonenum{i});
end
end
then error:Undefined function 'eq' for input arguments of type 'cell'.
</pre>Roger/matlabcentral/answers/contributors/4198367-rogertag:www.mathworks.nl,2005:Question/1544492014-09-12T00:39:27Z2014-09-15T02:43:27ZHow to make 'blue' variable?<p>Hi all, I'm trying to make my own ImageViewer. Using some program as a template, I saw a lot of 'blue' variables in it (when I point on such variable there is a text "The scope of variable ... spans multiple function").</p><p>Now I understood, that I want to use such variables also - in callback functions to update text, data, and so on.</p><p>How can I create such variables?
Short explanation of what does it mean is appreciated as well.
Thanks.</p>Mikhail/matlabcentral/answers/contributors/5492695-mikhailtag:www.mathworks.nl,2005:Question/1548352014-09-15T02:26:52Z2014-09-15T02:26:52ZHow to calculate color power from wavelength spectrum graph<p>How can i calculate the Power of each color from wavelength spectrum graph.
Actually i am calculating the BLUE LED converting efficiency.
The Graph i got shows the POWER of total LIGHT (red, green, blue), now i want to process that graph in MATLAB and want to calculate the power of each color separately.</p>TAYYAB/matlabcentral/answers/contributors/1371078-tayyab