http://www.mathworks.de/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2014-07-23T03:22:58Ztag:www.mathworks.de,2005:Question/1420402014-07-16T08:15:00Z2014-07-23T03:22:58ZHow to labeling the tip of the head and the end of the tail of this fish image? Like how i did with the center of the fish using centroid.<p>i attach the image for reference if you do not understand. have problem putting a label on the head and tail.</p>Tommy/matlabcentral/answers/contributors/5396873-tommytag:www.mathworks.de,2005:Question/1428612014-07-22T06:37:29Z2014-07-23T03:16:21ZDecode and Forward Scheme vs Direct Transmission<p>i need to show that relay transmission via decode and forward scheme is better than direct transmission. SNR vs BER Plot is required. Can somebody please share the code, Its urgent Please.</p>Sad Tal/matlabcentral/answers/contributors/5475621-sad-taltag:www.mathworks.de,2005:Question/1428772014-07-22T10:00:01Z2014-07-23T03:16:18Z Image acquisition toolbox app <p>How to capture video frames or images with uncompressed format in Image acquisition toolbox app,I'm using matlab-2013a and I have connected my logitech webcam c525 to the system</p>Sagar/matlabcentral/answers/contributors/5416206-sagartag:www.mathworks.de,2005:Question/1429872014-07-23T03:13:34Z2014-07-23T03:13:34ZNo Correlation Between The Shows Tonight With The Date<p>No Correlation Between The Shows Tonight With The Date, Check here about Geordie Shore premiere of season 8 and PLL latest installment 5x7.</p><p><a href = "http://www.applesandsage.com.au/Blog/geordieshore/post/season-8-episode-1">http://www.applesandsage.com.au/Blog/geordieshore/post/season-8-episode-1</a> <a href = "http://davars.com/blog/geordieshoreseries8/post/episode1premiere">http://davars.com/blog/geordieshoreseries8/post/episode1premiere</a> <a href = "http://blogs.itramblings.com/geordieshore8x1/post/se8ep1">http://blogs.itramblings.com/geordieshore8x1/post/se8ep1</a> <a href = "http://www.galactica.com.cy/content/putlocker-8x1-watch-geordie-shore-season-8-episode-1-free-online">http://www.galactica.com.cy/content/putlocker-8x1-watch-geordie-shore-season-8-episode-1-free-online</a> <a href = "http://www.ign.com/boards/threads/stream-geordie-shore-season-8-episode-1-online-premiere.454124955/">http://www.ign.com/boards/threads/stream-geordie-shore-season-8-episode-1-online-premiere.454124955/</a> <a href = "http://socjobs2009.proboards.com/thread/1476/geordie-series-episode-online-stream">http://socjobs2009.proboards.com/thread/1476/geordie-series-episode-online-stream</a> <a href = "http://grandiflora.net/node/1675">http://grandiflora.net/node/1675</a> <a href = "http://horizoncraft.fr/forum/index.php?/topic/320025-replay-watch-geordie-shore-season-8-episode-1-online-and-free/">http://horizoncraft.fr/forum/index.php?/topic/320025-replay-watch-geordie-shore-season-8-episode-1-online-and-free/</a></p><p><a href = "http://forum.modernmayor.com/forum/the-idea-room/3149-replay-watch-pretty-little-liars-season-5-episode-7-online-stream">http://forum.modernmayor.com/forum/the-idea-room/3149-replay-watch-pretty-little-liars-season-5-episode-7-online-stream</a> <a href = "http://horizoncraft.fr/forum/index.php?/topic/320513-stream-hd-watch-pretty-little-liars-season-5-episode-7-online-full-replay/">http://horizoncraft.fr/forum/index.php?/topic/320513-stream-hd-watch-pretty-little-liars-season-5-episode-7-online-full-replay/</a> <a href = "http://www.ign.com/boards/threads/recap-pretty-little-liars-season-5-episode-7-online.454125055/">http://www.ign.com/boards/threads/recap-pretty-little-liars-season-5-episode-7-online.454125055/</a> <a href = "http://pll5x7.wordpress.com/">http://pll5x7.wordpress.com/</a> <a href = "http://www.galactica.com.cy/content/updated-video-watch-pretty-little-liars-season-5-episode-7-online-free-stream">http://www.galactica.com.cy/content/updated-video-watch-pretty-little-liars-season-5-episode-7-online-free-stream</a></p>Alvaro/matlabcentral/answers/contributors/5477244-alvarotag:www.mathworks.de,2005:Question/1429532014-07-22T19:00:38Z2014-07-23T02:38:00ZHow to compile and deploy SimBiology file on the web<p>Hi everyone. Really need someone to assist me on this matter. I have an *.sbproj file. I know that we need to export the file and use the exported model in order to deploy it in a standalone application. But, how can I use this file for the deployment in the web? I don't have any idea on how to create the *.jar file for this case. One of the example show it this way (for standalone application),</p><pre class="language-matlab">mccCommand = ['mcc -m T1.m -N -p simbio -a exportedM1.mat', dependencies_2];
</pre><p>But since I need it to be in a *.jar file, I don't know how to do it. Hope someone could show me the right way to do this. Any examples will be very much appreciated. For your information, I am using Eclipse Kepler to build Java servlet and JSP and using Tomcat as the server. Thanks in advance!</p>Zetty Zakaria/matlabcentral/answers/contributors/5209262-zetty-zakariatag:www.mathworks.de,2005:Question/1429792014-07-22T23:29:06Z2014-07-23T02:13:38ZMSE between a set of data points (x,y) and a defined line<p>Hi all,</p><p>I'm a psychologist and i'm totally new to Matlab.
I'm trying to reproduce an analysis reported in a scietific paper where the researcher compared a curve drawn by participants with an ideal straight line using a formula representing the square of the root mean square (in the attachment the piece of the paper where the analysis is reported).</p><p>What i have now is a series of coordinates (a file .dat) divided in two columns (X,Y), representing what the subject has drawn (actual trajectory) with the mouse and i also have the two points where the ideal trajectory should be.</p><p>From the formula I understood that the RMS should be computed based on the defined integral (defined by the last X of the subject and the first X of the movement done by participant) of the square of the subtraction between the two functions (actual and ideal). My main problem is that i don't know what should i put as the argument of the integral (what should i subtract). Their results of the formula are always oscillating between 0.0001 and 0.05.</p><p>I've tried a simple piece of code (below) where i tried to subtract the integrals of the two curves (i guess basically subtracting the areas) but i really don't think is what i should be doing here.</p><p>Thank you in advance for your help,</p><p>Alessandro</p><pre class="language-matlab">% % % % % % % % % %
% Lines comparisons%
% % % % % % % % % %
</pre><pre class="language-matlab">load my_xy.dat; % read actual trajectory data into the my_xy matrix
Xr = my_xy(:,1); % copy first column of my_xy into Xr(eal)
Yr = my_xy(:,2); % copy second column of my_xy into Yr(eal)
Xd = my_xy (:,3);
Yd = my_xy (:,4);
</pre><pre class="language-matlab">Xc = [0.0,503.46];% Xc(orrect) ideal line x coordinates
Yc = [-352,151.46];% Yc(orrect) ideal line y coordinates
</pre><pre class="language-matlab">plot(Xr,Yr,'--',Xc,Yc); % plot actual trajectory and ideal trajectory
</pre><pre class="language-matlab">% 1) trying to replicate the formula but not succeding
MSE = ((trapz(Xr,Yr)-trapz(Xc,Yc)).^2)/(Xr(end)-Xr(1));
</pre>Alessandro/matlabcentral/answers/contributors/3356237-alessandrotag:www.mathworks.de,2005:Question/1427092014-07-21T03:23:13Z2014-07-23T02:05:13ZGenerating Hessian of the Lagrangian with dynamic number of nonlinear constraints in Fmincon<p>Hi,</p><p>(I posted this in stack exchange 2 days back but didn't get a response. Hope it works here).</p><p>I'm using interior point algorithm for solving a nonlinear optimization problem and want to provide Hessian of the Lagrangian as part of fmincon to speed up the process (running couple of thousand variations for different sets of parameters)</p><p>The workflow that I'm designing has the (nonlinear) objective function, form of linear and nonlinear constraints each in separate function files. I use a master script which has the fmincon. Since i'm running different variations of the problems, sometimes there may be zero nonlinear equality & zero nonlinear inequality constraints and in other scenarios, nonzero number of nonlinear equality/inequality constraints. In short the number of nonlinear constraints are dynamic and stored in the 2 variables "NumOfNonLinEqConstr" and "NumOfNonLinInEqConstr"</p><p>I have taken a look at <a href = "http://www.mathworks.com/help/optim/ug/symbolic-math-toolbox-calculates-gradients-and-hessians.html">Generating Hessian using Symbolic toolbox</a> and few other web-pages but cannot see an example where the Hessian of the Lagrangian is constructed for dynamic number of constraints. In the referred matlab webpage example, like in one variation I tried replacing 10 with NumOfNonLinInEqConstr bu it doesn't work as matlabFunction does not work on cell data type. Can anybody provide a working example for constructing hessian of the lagrangian with dynamic number of nonlinear constraints</p><p>Relevant code lines from the matlab link provided below: My question is how could I avoid hard-coding 10 in the below code (and also avoid manual addition of the product of hessian of the constraint and lambda.ineqnonlin 10 times)?</p><pre> hessc = cell(1, 10);
for i = 1:10
hessc{i} = jacobian(gradc(:,i),x);
end</pre><pre> for i = 1:10
ii = num2str(i);
thename = ['hessc',ii];
filename = [currdir,thename,'.m'];
matlabFunction(hessc{i},'file',filename,'vars',{x});
end</pre><pre> function H = hessfinal(X,lambda)
%
% Call the function hessenergy to start
H = hessenergy(X);</pre><pre> % Add the Lagrange multipliers * the constraint Hessians
H = H + hessc1(X) * lambda.ineqnonlin(1);
H = H + hessc2(X) * lambda.ineqnonlin(2);
H = H + hessc3(X) * lambda.ineqnonlin(3);
H = H + hessc4(X) * lambda.ineqnonlin(4);
H = H + hessc5(X) * lambda.ineqnonlin(5);
H = H + hessc6(X) * lambda.ineqnonlin(6);
H = H + hessc7(X) * lambda.ineqnonlin(7);
H = H + hessc8(X) * lambda.ineqnonlin(8);
H = H + hessc9(X) * lambda.ineqnonlin(9);
H = H + hessc10(X) * lambda.ineqnonlin(10);</pre><pre> end</pre>Hari/matlabcentral/answers/contributors/4996260-haritag:www.mathworks.de,2005:Question/1429702014-07-22T21:22:31Z2014-07-23T01:59:00ZIncorect output from Merge block sometimes<p>The output from the Merge block is not producing the data I expected. I've IF ELSE block in the model. Only the data from the IF action block is shown, but not the ELSE action. I am almost certian the condtion in the ELSE action block is met sometimes. Please help.</p>William/matlabcentral/answers/contributors/1607267-williamtag:www.mathworks.de,2005:Question/1428962014-07-22T12:21:52Z2014-07-23T01:08:03ZBug in matlab R2012b version <p>Hello,</p><p>I use the MATLAB R2012b version and when I try this:</p><p>0.5:0.1:0.8 the answer is:</p><p>ans =</p><pre class="language-matlab">Columns 1 through 3
</pre><pre> 5.000000000000000e-01 6.000000000000000e-01 7.000000000000001e-01</pre><pre class="language-matlab">Column 4
</pre><pre> 8.000000000000000e-01</pre><p>Why the third term is not strictly equal to 0.7?
Furthermore when I try 0.5:0.1:0.9 the bug disappears!</p><p>Do you have an answer?
Note: (as a reminder go to "HOME", "Preferences" and select "long e")</p><p>Thanks in advance
Fabrice</p>scarzo/matlabcentral/answers/contributors/5108130-scarzotag:www.mathworks.de,2005:Question/1428852014-07-22T10:47:57Z2014-07-23T00:09:43ZShifting state space variables by constant value<p>Hi,</p><p>I have a discrete time state space model for which I want to shift the state variables by a constant value. The actual model is as follows,</p><pre class="language-matlab">x(k+1) = Ax(k) + Bu(k)
</pre><p>It is a 4-state system. The goal is to change state variables and input to the following variable.</p><pre class="language-matlab">z(k) = x(k) - c
</pre><pre class="language-matlab">v(k) = u(k) - c
</pre><p>Where c is a constant.
My question here is, how shall this change of variable be implemented to change the state space equation accordingly. Is the following change going to work? I could not see similarity transform working here.</p><pre class="language-matlab">z(k+1) = Az(k)+ Ac + Bv(k) + Bc
</pre><p>Am I missing anything here? Please advise of your thoughts.</p><p>Thank you.</p>Salman/matlabcentral/answers/contributors/5334362-salmantag:www.mathworks.de,2005:Question/1429772014-07-22T23:22:43Z2014-07-22T23:57:44ZFast way to save data<p>Hi,</p><p>I'm writing a matlab code that performs sensitivity analyses on a crop model. It composes data into a table and saves it as a text file. It then executes another application with that file as the input, and saves the output in an array. It repeats this process about a million times.</p><p>Currently, a million iterations takes about 5 days. Using the profiler, I identified the functions that take the most time (more than half the total execution time) are all functions used to save the data table as a text file. I was wondering if you guys had any tips on how to improve this to make the program faster?</p><p>Thanks!</p>Johan/matlabcentral/answers/contributors/5369792-johantag:www.mathworks.de,2005:Question/1429832014-07-22T23:47:00Z2014-07-22T23:49:52ZHow can I delete an entire row in a matrix and shift the rest of the matrix below the deleted row up each time I delete??<p>I want to delete an entire row and shift the remaining matrix below the deleted row up by one, each time I delete a row.</p>Allan N/matlabcentral/answers/contributors/574658-allan-ntag:www.mathworks.de,2005:Question/1429802014-07-11T04:00:00Z2014-07-22T23:43:04ZHow can I download the data files for MATLAB R2014a without installing MATLAB?<p>I need to download MATLAB without installing it, but I understand that for R2014a and later, the installation and download process is one and the same. How can I download MATLAB without installing it?</p>MathWorks Support Team/matlabcentral/answers/contributors/4622813-mathworks-support-teamtag:www.mathworks.de,2005:Question/1429812014-07-17T04:00:00Z2014-07-22T23:43:04ZWhy am I unable to immediately restart the license manager after stopping it on Linux?<p>When my license manager crashes or I stop the process, I am unable to immediately restart the license manager. I am seeing errors similar to the following in my log file:</p><p> </p><p>14:03:20 (lmgrd) The TCP port number in the license, 27200, is already in use. </p><p>14:03:20 (lmgrd) Possible causes: </p><p>14:03:20 (lmgrd) 1) The license server manager (lmgrd) is already running for this license. </p><p>14:03:20 (lmgrd) 2) The OS has not "cleared" this port since lmgrd died. </p><p>14:03:20 (lmgrd) 3) Another process is using this port number (unlikely). </p><p>14:03:20 (lmgrd) Solutions: </p><p>14:03:20 (lmgrd) 1) Make sure lmgrd and all vendor daemons for this </p><p>14:03:20 (lmgrd) license are not running. </p><p>14:03:20 (lmgrd) 2) You may have to wait for the OS to clear this port. </p><p>14:03:20 (lmgrd) Retrying for about 5 more minutes </p><p>14:03:38 (lmgrd) Still trying... </p><p>14:03:56 (lmgrd) Still trying...</p><p> </p><p>OR</p><p> </p><p>13:31:30 (lmgrd) Failed to open the TCP port number in the license.</p>MathWorks Support Team/matlabcentral/answers/contributors/4622813-mathworks-support-teamtag:www.mathworks.de,2005:Question/1429062014-07-22T13:51:41Z2014-07-22T23:41:10ZHow to only have user select data file if workspace is empty?<p>I have a generic code that calculates things based off of the data file that the user selects and loads into the Matlab Workspace. Here is my code to do that:</p><pre class="language-matlab">%% Load Data
% Open Matlab file (ATI data)
[a,b]=uigetfile('*.mat');
FileATI=fullfile(b,a);
dataATI = load(FileATI);
</pre><p>I know there is some intrinsic function like "if isempty" that would prevent me from having to select the file every single time I re-run my code. How would I do this? Thanks so much, in advance!</p>Kelsey/matlabcentral/answers/contributors/3821026-kelseytag:www.mathworks.de,2005:Question/1429732014-07-22T22:05:06Z2014-07-22T23:40:43ZWhy is bvp4c not able to faithfully solve the Poisson Boltzmann equation ?<p>Hi ,</p><p>I am trying to numerically solve the Poisson-Boltzmann equation for electrolytes in a solution using MATLAB. The equation can be written as 2nd order non linear ordinary differential equation.</p><p>Some of the relevant terms and symbols (as used in my code are explained below.</p><img src = "/matlabcentral/answers/uploaded_files/15736/pbe.gif"><p>I have got 2 boundary conditions : psi = 0 at x = 0 and psi = 0 at x = inf ( or a very large distance away from x = 0)</p><p>Below is my MATLAB code :-</p><pre class="language-matlab">function [sol] = pbeexp()
el = 4.8*10^-10; %electron charge in StatCoulomb in CGS
eps = 80; %permittivity of water at 20 degrees C
k = 1.3807*10^-16; %Boltzmann constant in CGS
T = 293 ; %absolute temperature at 20 degrees C
l = el^2/(eps*k*T);%Bjerrum length in cm
pn = k*T/el; %non dimensional potential
psiwall =300*10^-3*0.00333564; %Electric field at the electrode in StatVolts
%Formulating the problem
x=linspace(0,35*10^-7,10000)/l;%Linearly distributed grid
solinit = bvpinit(x,[psiwall/pn 0]); % Initial mesh
options = bvpset('RelTol',1e-5,'AbsTol',1e-5); % Tolerance values
</pre><pre class="language-matlab">sol = bvp4c(@pbeode,@pbebc,solinit,options);%Initial solution structure
xint=linspace(sol.x(1),sol.x(end),size(sol.x,2));%Linearly distributed grid
sxint=deval(sol,xint);
dist = xint;
pot = sxint(1,:);
plot(dist,pot)
</pre><pre class="language-matlab">function dydx = pbeode(x,psi)
el = 4.8*10^-10; %electron charge in StatCoulomb in CGS
eps = 80; %permittivity of water at 20 degrees C
k = 1.3807*10^-16; %Boltzmann constant in CGS
T = 293 ; %absolute temperature at 20 degrees C
l = el^2/(eps*k*T);%Bjerrum length in cm
H = 7.8*10^-7; %length of probe in cm
a3 = (1/4.6)*10^3 ; %steric packing in cc
czero = 6.023*10^20*0.1 ; %bulk counterion concentration
nu = 2*czero*a3; %steric size parameter for use in solution
%% Non - dimensional quantities
pn = k*T/el; %non dimensional potential
%% PBE terms for different components of the model
A1 = (4*pi*czero*l*sinh(psi(1)))/(1+2*nu*((sinh(psi(1)/2)^2)));% expression for counterions in the solution
dydx = [ psi(2)
(2*l^2*A1)];
end
%% Providing the B.C.s
function bc = pbebc(psia,psib)
psiwall = 300*10^-3*0.00333564; %Electric field at the electrode in StatVolts
pn = k*T/el; %non dimensional potential
bc = [ psia(1)-psiwall/pn
psib(1)];
end
end
</pre><p>When I run the code the resulting plot of "psi" vs "x" is coming as linear.</p><img src = "/matlabcentral/answers/uploaded_files/15739/abc.jpg"><p><b>However according to published data it should decay down to zero in an exponential manner!!</b>
One link is provided below :- <a href = "http://www.kirbyresearch.com/index.cfm/wrap/textbook/microfluidicsnanofluidicsse55.html">http://www.kirbyresearch.com/index.cfm/wrap/textbook/microfluidicsnanofluidicsse55.html</a>.</p><p><b>Could anyone please run the code and instruct me in troubleshooting ? What is wrong with my modelling ?</b></p>AG4102M/matlabcentral/answers/contributors/4951159-ag4102mtag:www.mathworks.de,2005:Question/1429572014-07-22T19:24:16Z2014-07-22T23:36:41ZSolving two systems of DEs using the ode45 function.<p>I am trying to solve two systems of differential equations in variables x1, x2, x3 using the ode45 function. The equations are given below:</p><p>dx1=-2*lambda*beta*x1+2*lambda*alpha*x2+lambda^2*sigma^2;</p><p>dx2=beta*x1-(alpha+lambda*beta)*x2+lambda*alpha*x3;</p><p>dx3=2*beta*x2-2*alpha*x3;</p><p>where alpha=alpha0+alpha1*t and beta=beta0+beta1*t and alpha0, alpha1, beta0, beta1, sigma, lambda are known constants.</p><p>The values I am trying to find are X1, X2 and X3. The derivatives of these desired values are given by:</p><p>dX1=beta*x1;</p><p>dX2=alpha*x2;</p><p>dX3=x3;</p><p>I am having difficulties implementing the above using the ode45 function given that the problem is defined by two sets of simultaneous differential equations. Any suggestions as to how this can be solved would be much appreciated. Thanks.</p>Vassil Botev/matlabcentral/answers/contributors/5157947-vassil-botevtag:www.mathworks.de,2005:Question/1429632014-07-22T20:11:47Z2014-07-22T23:36:38ZHow to specify the generated code in initialization section with Mathworks embedded coder?<p>In auto code using 2011a, it always inserts some "custom signals" in initialization secion such as
x1 = ((uint16_T)0U);
x2 = ((uint16_T)0U);
x3 = ((uint16_T)0U);</p><p>as shown below. I 'm not sure how this part code is generated and how to specify the code generated for "custom signals" if I need.</p><p>Thanks,
Yixin</p><p>void Example_initialize(void)
{
/* Registration code */</p><pre class="language-matlab">/* block I/O */
</pre><pre class="language-matlab">/* custom signals */
x1 = ((uint16_T)0U);
x2 = ((uint16_T)0U);
x3 = ((uint16_T)0U);
...
}
</pre>Yixin/matlabcentral/answers/contributors/2932156-yixintag:www.mathworks.de,2005:Question/1428402014-07-21T23:56:48Z2014-07-22T23:32:14ZWhy would the R2cv be higher than the R2cal?<p>I'm running Raman Spectroscopy data through the PLS Toolbox to predict various parameters of meat and I am continually getting R2cv values a lot higher than R2cal values. The toolbox is set to cross validate using leave- one- out cross validation with 20 maximum LVs and I have 80 samples.</p><p>For example, predicting tenderness using Raman Spectra has given me R^2 Cal: 0.00102829
R^2 CV: 0.288515.</p><p>Any ideas as to what could possibly be going on or how I can make sense of it would be much appreciated.</p>Stephanie/matlabcentral/answers/contributors/4591912-stephanietag:www.mathworks.de,2005:Question/1429282014-07-22T15:30:54Z2014-07-22T23:29:20Zhow can i plot the simulation results while using sim command and set_param command<pre class="language-matlab">i=0;
while i<1
sim('Testung',[i,i+0.1])
set_param('Testung/Resistor','Resistance','i')
i=i+0.1;
end
</pre><p>i always get the plot in the scope from t_sim=1 to t_sim=1.1.
But how can i get the hole simulation results in the scope?
ty thomas</p>Thomas/matlabcentral/answers/contributors/3880183-thomastag:www.mathworks.de,2005:Question/1429662014-07-22T20:27:46Z2014-07-22T23:20:56ZHow to solve simultaneous trigonometric equation with summation from n=1 to inf. ?<p>I am trying to solve the set of simultaneous equations (shown in file attached, see bottom). x and y are known. For a particular value of psi3, I have to obtain psi1 and psi2 from these simultaneous equations?
I wonder if a combination of 'symsum' and 'solve' command will give a solution as the series is not convergent. In that case, how many terms should I take in the series? Never encountered such a set of equations.
Any kind of help is appreciated.Thanks for kindness.</p>Dinesh Kumar/matlabcentral/answers/contributors/4352325-dinesh-kumartag:www.mathworks.de,2005:Question/1429332014-07-22T16:31:35Z2014-07-22T22:58:28ZCreate new variable that recognizes changes in the code <p>I have a double matrix B that has in C1 the year 1998 and in C2 a code (unrepeated). Each C2 is given a value in C3.</p><pre class="language-matlab">% C1 C2 C3
B=[ 1998 22 37
1998 34 7
1998 76 12
1998 98 29
1998 107 14
…]
</pre><p>This is how I got to B:</p><pre class="language-matlab">N1=[N{:,1} N{:,2} N{:,3}];
N1=unique(N1(:,1:3),'rows');
N3= unique(N1(:,1:2),'rows');
for m=1:size(N3,1)
N3(m,3)=sum(N1(:,1) == N3(m,1) & N1(:,2)==N3(m,2));
end
B=N3((N3(:,1) == 1998),:);
</pre><p>I have a cell-array A with the years horizontally disposed in R1, un-repeated values in Y, and corresponding codes in the columns that follow. The codes are the same as in C2 from variable B, but disposed differently.</p><pre class="language-matlab">A={Y 1996 1997 1998 1999 %R1
1 107 107 22 22
13 98 98 76 1267
… }
</pre><p>Is there a way I could get a new variable that recognizes the change in the codes in variable A, and presents the corresponding values from C3 in B? For instance:</p><pre class="language-matlab">AB={Y Initial C2 Change C2
1 107 14 22 37
13 98 29 76 12 }
</pre>Maria/matlabcentral/answers/contributors/5049159-mariatag:www.mathworks.de,2005:Question/1407782014-07-07T19:31:42Z2014-07-22T22:41:36Zhow can i convert the recorded voice into noise using any algorithm in matlab?<p>i'm trying to make my own algorithm which is capable of converting the reocrded voice into noise, and when i apply the reverse process on the converted voice; i.e. noise, i should get the original recorded voice. well, i'm doing this, so that if someone plays that voice, it appears to him like a noise.. and when i perform the reverse operation on that converted voice, i.e. noise, i should get the original voice back? here's the code how em making the recorded voice into noise? this code is working but upto certain extent. the recorded voice is converted into noise but one can hear the original voice in the background, and if someone plays that noise into some audio player using slow mode, a man can hear that voice.. can someone do some modifications in that code,so that i should completely become the noise and no one can hear that voice, even if someone plays that voice in some audio player in slow mode.. and when i apply the reverse process, i should get the original voice back.. the code is:</p><pre class="language-matlab">c=wavread('haseeb');
</pre><pre class="language-matlab">a=(c-min(c))/(max(c)-min(c)); % normalization to bring the voice values in the range [0,1]
</pre><pre class="language-matlab">for i=1:length(a)
</pre><pre class="language-matlab">% speading the values into the range[-1,1]
</pre><pre class="language-matlab">if((a(i,1)>=0)&&(a(i,1)<=0.2))
b(i,1)=a(i,1)-1;
</pre><pre class="language-matlab">elseif((a(i,1)>0.2)&&(a(i,1)<=0.4))
b(i,1)=a(i,1)+0.6;
</pre><pre class="language-matlab">elseif((a(i,1)>0.4)&&(a(i,1)<=0.6))
b(i,1)=a(i,1)-0.5;
</pre><pre class="language-matlab">elseif((a(i,1)>0.6)&&(a(i,1)<=0.8))
b(i,1)=a(i,1)-1.2;
</pre><pre> elseif((a(i,1)>0.8)&&(a(i,1)<=1))
b(i,1)=a(i,1)-0.4;</pre><pre class="language-matlab">else
end
</pre><pre class="language-matlab">end
</pre>haseeb/matlabcentral/answers/contributors/5291063-haseebtag:www.mathworks.de,2005:Question/1429692014-07-22T21:03:23Z2014-07-22T22:39:25ZHow to compare 2 different size binary images?<p>I need to find traffic sign in an image.
I segmented the image suuccessfully, so now I got cropped binary image of the sign:</p><img src = "/matlabcentral/answers/uploaded_files/15735/example.jpg"><p>How can I check whether the sign exist in the image or not?</p><p>I tried using xcorr2, but I get better correlation comparing wrong sign.</p><p>Thanks in advance,
Matanya.</p>Matanya/matlabcentral/answers/contributors/4350096-matanyatag:www.mathworks.de,2005:Question/1429712014-07-22T21:26:22Z2014-07-22T22:24:07Zhow to write for loop with two variables<p>Hello,
I'm having problem with this it of code:</p><pre class="language-matlab">for j = 1:3
for m = 3:-1:1
imagesc(images{m}, 'XData', [fid1(j,1) (size(Image1,2) + fid1(j,1))], 'YData',[fid2(j,1) (size(Image1, 1) + fid2(j,1))]), axis equal, axis xy
alpha(0.7)
hold on
end
end
</pre><p>As you can see, I want the images{m} to start from 3 and end at 1, while the fid1(j,1) commands to go in the opposite direction.
Any ideas how to solve this? One idea I had was to flip my images{m} array but I'm not sure how to do this</p><p>Thanks</p>mika tarhuni/matlabcentral/answers/contributors/5477194-mika-tarhunitag:www.mathworks.de,2005:Question/1429512014-07-22T18:50:51Z2014-07-22T22:15:34ZEval on multi-line strings - no return value?<p>I'm using R2011b. I'm trying to evaluate a string, potentially with multiple lines, and obtain a final return value.</p><p>For example:</p><pre class="language-matlab">sprintf('a=25\nif (a == 30)\n a = 75;\nelse\n a =42\nend\n37')
result = eval(ans)
</pre><p>Produces: "Error: The expression to the left of the equals sign is not a valid target for
an assignment."</p><p>For clarity, the sprintf result is:</p><pre class="language-matlab">ans =
</pre><pre class="language-matlab">a=25
if (a == 30)
a = 75;
else
a =42
end
37
</pre><p>The error is confusing to me, as I would expect the last line of this block to return a value of 37. For example:</p><pre class="language-matlab">sprintf('37')
result = eval(ans)
</pre><p>Creates a result variable with value of 37, as I would expect.</p><p>Further troubling me is the fact that:</p><pre class="language-matlab">sprintf('a=25\nif (a == 30)\n a = 75;\nelse\n a =42\nend\n37')
eval(ans)
</pre><p>Executes appropriately, and even updates the ans variable to 37.. which to me implies that MATLAB kind of knows there is a return value for this code block. Thus this adds to my confusion as to why I can't override the assignment to ans with a new variable... it's like, it's too late if you are evaling a multi-line block, but not a single line expression.</p><p>Can anyone explain the fault in my expectations here?</p><p>thanks!</p>Mark/matlabcentral/answers/contributors/5476946-marktag:www.mathworks.de,2005:Question/1428502014-07-22T03:15:26Z2014-07-22T22:14:19ZStateflow Simulink Function Multiple Sample Times<p>I'm gathering from information that this may not be possible, but I want to have a Stateflow chart contain several different controllers, each running at different rates/sample times. It seems as though the chart can only contain one sample time, though, and the functions can only inherit.
Is there a way to do this? Or will I just have to avoid Stateflow and use action subsystems?</p><p>Thanks,
Ben</p>Ben/matlabcentral/answers/contributors/5439421-bentag:www.mathworks.de,2005:Question/1428922014-07-22T11:40:41Z2014-07-22T22:10:15ZHow to generate a HDL code for a buck converter using Mtalab simulink and xilinx system Generator<p>Hello,</p><p>Im working on implementing a buck converter model with it PID Controller on FPGA (Spartan 3 and 3An
Xc3s700a package :fg484 speed-4 ) using simulink of Matlab2012 a and xilinx system generator 14.2 i want to generate a HDL code for this model which is based on simpowersystems in Simulink. Can you please help me find a solution for this problem ? Do i have to eliminate the buck converter model and replace it with it transfert function or another simulink model?</p>amouna/matlabcentral/answers/contributors/5428628-amounatag:www.mathworks.de,2005:Question/1429382014-07-22T17:26:28Z2014-07-22T22:03:37ZSearch url inside another url in matlab....<p>i want to search a url inside another url...
for example www.youtube.com i want to search it in www.zalmos.com or www.awebproxy.com.
thanks....
need matlab code......</p>azizullah khan/matlabcentral/answers/contributors/3587681-azizullah-khantag:www.mathworks.de,2005:Question/1429642014-07-22T20:15:24Z2014-07-22T21:53:49ZTrouble Compiling Code Dependent on Folder Locations<p>My script requires the user to place input text files in a specific directory. This directory is pre-made, and is referenced by name and location relative to the script's location. This specific directory is not maintained during compilation. How can I get around this?</p>Kevin/matlabcentral/answers/contributors/3741898-kevintag:www.mathworks.de,2005:Question/1429722014-07-22T21:28:38Z2014-07-22T21:38:27Zgetting 32 bit version for 64 bit machine<p>Hello. A debugging tool from CSR that I want to use requires 32-bit MATLAB. I have been successfully running 64-bit MATLAB on my 64-bit PC for a few years now.</p><p>1) When I download MATLAB from mathworks.com, it defaults to the 64-bit version without giving me control. How can I get the 32-bit version?</p><p>2) I assume I can have both the 32 bit and 64 bit versions on my PC? I read a 2010 Answeres response that basically said "yes but be sure to use different directories but the same release".</p>Jay Kirsch/matlabcentral/answers/contributors/2255353-jay-kirschtag:www.mathworks.de,2005:Question/1425292014-07-19T10:48:32Z2014-07-22T21:29:43Zfmincon in matlab for multi objective<p>Hello
I am a question please</p><p>can I use fmincon function for solving multi objective linear programming in Matlab?</p><p>I want to create two m files, one of them is as objective function and the other is as constraint function and then I want to use fmincon to solve them.</p><p>can I do that? Is it true?</p>fatema saba/matlabcentral/answers/contributors/5419261-fatema-sabatag:www.mathworks.de,2005:Question/1428442014-07-22T00:56:51Z2014-07-22T21:28:45ZHow do I calculate a threshold from one ROI and calculate a mean from a larger ROI that only takes into account pixels above this threshold?<p>I've never coded a Matlab program to analyze images so I'm having some trouble with this. What I'd like to do is take the mean brightness/intensity of a small region of interest, set a threshold 2 SD below this mean, and then find the mean of a larger region of interest only taking into account the values above threshold. Could anyone help me with this?</p>Roshmi/matlabcentral/answers/contributors/5443386-roshmitag:www.mathworks.de,2005:Question/957942013-08-16T21:31:00Z2014-07-22T21:24:17ZWhy do I receive an Error 348 when attempting to activate my Individual, Group Member, or Student Version license?<p>When trying to activate my license, I receive the error message:</p><pre class="error">
A Licensed End User is already associated with this license. Please contact your license administrator for assistance</pre><p>How do I activate my license?</p>MathWorks Support Team/matlabcentral/answers/contributors/4622813-mathworks-support-teamtag:www.mathworks.de,2005:Question/1420272014-07-16T06:27:23Z2014-07-22T21:11:30ZHow to recognize human face shapes like oval,round....using mathlab?<p>i am new to image processing and mathlab,please give me any idea regarding recognizing the human face shape</p>lakshan/matlabcentral/answers/contributors/5445778-lakshantag:www.mathworks.de,2005:Question/1429582014-07-22T19:51:36Z2014-07-22T21:10:38ZHow do i plot the 3d profiles graph located below in matlab.<p>I am looking to reproduce the graph below. I have the formula and I am using matlab. But I can only get an arc. I cannot get the graph to look like that.
Thanks</p>Nismeta/matlabcentral/answers/contributors/5432022-nismetatag:www.mathworks.de,2005:Question/1429442014-07-22T17:51:35Z2014-07-22T21:07:52ZHow to migrate all settings, preferences, histories, layouts, ... _everything_ user related from 2013a to 2014a?<p>I spent significant time and effort to get the user interface for v2013a set up exactly the way I wanted it. Plus, my use of matlab is ongoing. What I was doing yesterday using 2013a, I want to continue today using 2014a.</p><p>A migration of all user-related info ought to be about the first thing that matlab does when upgrading between versions. But it does not. Therefore there ought to be something inthe installation manual, or at least a README file that explains how to make the yearly transition seamless. If there is something there, I cannot not find it.</p><p>According such documentation as I could find, all one has to do is delete the 2014a prefs folder,</p><p>C:\Users\<user name>\AppData\Roaming\MathWorks\MATLAB\R2014a</p><p>and matlab will automatically recreate it and migrate everything from</p><p>C:\Users\<user name>\AppData\Roaming\MathWorks\MATLAB\R2013a</p><p>to the new version.</p><p>Well, of course it does not. I've tried manually copying the contents of the 2013a folder to the 2014a folder, but that results in a huge spewing of java errors on the command window when I attempt to open the history window. It appears that nothing at all is migrated.</p><p>So, how do I do migrate ALL my settings, histories, layouts, paths, etc. from one version to the next?</p>Alan Peters/matlabcentral/answers/contributors/2467902-alan-peterstag:www.mathworks.de,2005:Question/920962009-12-22T15:29:00Z2014-07-22T21:06:56ZHow can I print line numbers when I use the PUBLISH command in MATLAB?<p>I want line numbers printed next to each line of my function when I publish functions using the PUBLISH command.</p><p>I would like to see something like</p><pre> 001 function y = MyFunc(x)</pre><pre> 002 y = x.^2;</pre><pre> 003 end</pre>MathWorks Support Team/matlabcentral/answers/contributors/4622813-mathworks-support-teamtag:www.mathworks.de,2005:Question/1429612014-07-22T20:05:10Z2014-07-22T21:05:17ZWhy can't I get the output while using 'webcam' command?<p>I have connected a webcam to my computer and try to get snapshot from matlab.
I viewed my webcam by typing 'webcamlist' in the command window and get the output
'USB Video Device'
But while typing only 'webcam' it shows error- "
Error getting the current Media Type". I know its a simple error but I can't cope with it.
However, I am using matlab R2014a and have installed image acquisition toolbox already. Please help me</p>Ekanto Arif/matlabcentral/answers/contributors/5364483-ekanto-ariftag:www.mathworks.de,2005:Question/1428112014-07-21T19:54:02Z2014-07-22T21:01:24ZMinimize second output of a function with respect to a variable. <p>Say I have an function of several variables with vector output, say, [a,b]=myfun(x,y,z);</p><p>Now, say I want to create a function that passes the parameters y and z and minimizes myfun with respect to x, so that the first output is minimized. So I could do something such as this:</p><p>function c = myfun2(x,y)</p><p>x0=1;</p><p>c = fminunc(@(x)myfun(x,y,x),x0)</p><p>end</p><p>But what if want to create a function, say fun3, that passes x and y as in fun2 but so that the <i>second</i> output of myfun is minimized. How could I do that without redefining myfun (or creating a new function) in an m file?</p>Peter Laslo/matlabcentral/answers/contributors/2387371-peter-laslotag:www.mathworks.de,2005:Question/1429542014-07-22T19:07:25Z2014-07-22T20:59:32Zhow to number selections in listbox?<p>hi, I have a listbox and its selections, when i click on the Add layer, a selection will be added in the listbox, now what i want is how to get that selection numbered so when I enter a name of a layer, it will automatically show 1.name of layer etc......
hope you can hekp me guuys and below there's an image so that you can understand well what i want
thanks</p>Jihad Chamseddine/matlabcentral/answers/contributors/5435815-jihad-chamseddinetag:www.mathworks.de,2005:Question/1324782014-06-04T20:54:45Z2014-07-22T20:52:56ZHow can I perform matrix operation efficiently?<p>I have an array X(n,m) where m<<n and n can be very large. First, I want to create a 3-d array of dimension (m,m,n) such that each mxm matrix in the nth location is the outer product of the n-th m-dimensional row in the original X- array.</p><p>Then I want to form a weighted sum all the mxm arrays where the weights are the elements of another n-dimensional array, Y(n).</p><pre class="language-matlab">result=zeros(m);
for i=1:n
result = result + Y(i) * X(i,:)' * X(i,:);
end
</pre><p>I could do this in the loop, but I think it would be slow when n is very large, compared to if there were a way to do all this with some matrix operation functions in MATLAB.</p>Ranjan Sonalkar/matlabcentral/answers/contributors/751939-ranjan-sonalkartag:www.mathworks.de,2005:Question/1429482014-07-22T18:34:57Z2014-07-22T20:49:16ZDatabase toolbox is not included in compiled standalone<p>I am running into an issue where Matlab Compiler is not adding the Database toolbox to my compiled output even if I specifically include it. The error message I get when calling the database function is:</p><pre class="language-matlab">Undefined function 'database' for input arguments of type 'char'.
</pre><p>The mcc command I am running has</p><pre class="language-matlab">-a "$matlabroot\toolbox\database
</pre><p>where $matlabroot is the full path to the install directory. When I look at the output in the ctfroot directory, I see many of the toolboxes included, but database is not one of them. I have confirmed that I have a valid license for this toolbox.</p>Greg/matlabcentral/answers/contributors/5364346-gregtag:www.mathworks.de,2005:Question/1429682014-07-22T20:47:02Z2014-07-22T20:47:02ZNeed Help with FFT <p>I am very new to Matlab and i know this question has been asked many times before but i have been having problem understanding the Matlab language.</p><p>So I have a set of data Power vs Time in an excel sheet and i want to convert that from time domain to frequency domain and plot it. how can i do so. please help</p>Muhammad/matlabcentral/answers/contributors/5477129-muhammadtag:www.mathworks.de,2005:Question/1089372013-12-06T17:52:46Z2014-07-22T20:44:51ZChange in matlab Window resolution after I open MuPAD app or Simulink<p>Recently I installed Matlab 2013b on my laptop with windows 8.1 operating system. Whenever I open matlab, the fonts look normal, I think it uses lower resolution. As soon as I open MuPAD app or Simulink, the matlab window size suddenly changes and it starts on higher resolution and the font size is reduced. Same thing happens even if I use external monitor. I've attached two pictures, matlab screen shot before I open the app and matlab screen after I open the app. Compare the toolbar strips or command history font size and you can see the difference. The later is so small, that its hard to read on my desktop. I have intel HD graphics, that comes with i7 processor, as well as NVIDIA graphics processor.</p><p>Earlier I was using Matlab 2012a, and it never had this issue even on Windows 8.1, and same laptop.</p><p>Thank you</p><p>-Punit</p><p>Before opening MuPAD app or Simulink:</p><img src = "/matlabcentral/answers/uploaded_files/5464/matlab_before.png"><p>after opening MuPAD app or Simulink:</p><img src = "/matlabcentral/answers/uploaded_files/5463/matlab_after.png"><p>>></p>Punit/matlabcentral/answers/contributors/1512217-punittag:www.mathworks.de,2005:Question/1429602014-07-22T20:03:50Z2014-07-22T20:42:04ZUsing try/catch to get warning message<p>What o I have to do in order to get rid of the message in ode45 line 309 (error tolerance message).
I use try and then I put the ode45(......) and eventually I`ll have a warning message about the tolerance for integration on the screen but I do not want this warning poping up all the time so I save the line 309 in ode45 and put it in a catch statement but it didnt work.
Can you guys help me with that.</p>Douglas Alves/matlabcentral/answers/contributors/5176052-douglas-alvestag:www.mathworks.de,2005:Question/1429622014-07-22T20:09:26Z2014-07-22T20:39:24ZDisplaying data in a printable matlab table<p>In the code below, I want to be able to display the t versus x values(usual table of values in algebra) in a printable table</p><p>t=0:30:360;
x =0.5*sind(t)
clf
plot(t, x, '-sk', 'LineWidth', 2)
table=[t',x']
The last line/command gives me a border-less table whose data mixed up/merged when exported to a word document. Please how may one create a printable matlab table containing data?</p>Chuzymatics Chuzymatics/matlabcentral/answers/contributors/3920901-chuzymatics-chuzymaticstag:www.mathworks.de,2005:Question/1428082014-07-21T18:58:03Z2014-07-22T20:37:52ZHeatmap and Contour figures in Matlab<p>Suppose that I have this information that first column is feature one of a motor, Second column is feature two and column three is response (in this case performance of motor).</p><pre class="language-matlab">[34 56 100
12 12 80
7 6 60
3 4 20
1 1 10.5
0 0 1]
</pre><p>I want have something like heatmap or contour that for example I have a warmer (for instance red color) for first row in matrix and more light color for row two and etc. What should I do?</p><p>Thanks.</p>Jack/matlabcentral/answers/contributors/5193869-jacktag:www.mathworks.de,2005:Question/1429592014-07-22T19:55:41Z2014-07-22T20:36:54ZRemove/replace ' i.e single quote from a sentance ...<p>asad'
want to replace ' and obtain
asad</p><p>need general code.</p>azizullah khan/matlabcentral/answers/contributors/3587681-azizullah-khantag:www.mathworks.de,2005:Question/1429672014-07-22T20:28:13Z2014-07-22T20:28:13ZHow to use Genetic algorithm for optimisation of derivatives<p>i have a set of equations including variables and their derivatives.how can i able to manage the situation using ga?</p><p>thanks.</p>Tapas/matlabcentral/answers/contributors/5477092-tapas