https://de.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2017-09-24T01:23:29Ztag:de.mathworks.com,2005:Question/3580752017-09-24T01:22:40Z2017-09-24T01:23:29ZThe expression to the left of the equals sign is not a valid target for an assignment.<p>I am very new to MATLAB and am trying to workout the distance between points which have been interpolated in a previous question. The following is what I have entered into MATLAB and am getting an Error saying that 'The expression to the left of the equals sign is not a valid target for an assignment'. I can't see any brackets missing from my functions.</p><p>X1 = [0,0;100,140.1235];</p><p>d1 = pdist(X1);</p><p>X2 = [100,140.1235;200,258.7626];</p><p>d2 = pdist(X2);</p><p>X3 = [200,258.7626;300,342.3485];</p><p>d3 = pdist(X3);</p><p>X4 = [300,342.3485;400,425.9343];</p><p>d4 = pdist(X4);</p><p>X5 = [400,425.9343;500, 509.5202];</p><p>d5 = pdist(X5);</p><p>X6 = [500,509.5202;558,558];</p><p>d6 = pdist(X6);</p><p>Total_Length = d1+d2+d3+d4+d5+d6</p>Clare Fergusonhttps://de.mathworks.com/matlabcentral/profile/authors/6480001-clare-fergusontag:de.mathworks.com,2005:Question/3580592017-09-23T20:38:15Z2017-09-24T01:13:47ZIndex exceeds matrix dimensions.<p>Here i want get values for y at each 30 m from L, thats why I chosed I =100 but there is something wrong 'Index exceeds matrix dimensions' how to modify this.
Index exceeds matrix dimensions.
Error in Q3 (line 33)
ym=(y(2:100)+y(1:99))/2;</p><pre class="language-matlab">clear;
%Input data
Q=10;
Z=3;
b=25;
L=3000;
So=0.001;
n=0.02;
g=9.81;
% range and increments of y
y=0:.1:10;
% Functions
A=b*y+Z*y.^2;
B=b+2*Z*y;
P=b+2*y*sqrt(1+Z^2);
S=Q^2*n^2./(A.^3.3333.*P.^-1.3333);
Fr=sqrt(Q^2*B./(g*A.^3));
%Find values of y where (S-So) and (Fr-1) cross zero
[S,t]=min(abs(S-So));
yN=y(t)
[S,t]=min(abs(Fr-1));
yc=y(t)
%Reset range and increments of y to go from critical
%to normal
clear y;
dy=0.2;
y=yc:dy:yN
%Calculate energy at new y values
A=b*y+Z*y.^2;
E=y+Q^2./(2*g*A.^2)
</pre><pre class="language-matlab">%Calculate x locations
ym=(y(2:100)+y(1:99))/2;
A_ym=b*ym+Z*ym.^2;
P_ym=b+2*ym*sqrt(1+Z^2);
S_ym=Q^2*n^2./(A_ym.^(10/3).*P_ym.^(-4/3));
x(1)=L;
for i=2:100;
x(i)=x(i-1)+(E(i)-E(i-1))/(So-S_ym(i-1));
end;
</pre>Shifohttps://de.mathworks.com/matlabcentral/profile/authors/10835987-shifotag:de.mathworks.com,2005:Question/3580742017-09-24T00:46:50Z2017-09-24T00:46:50Zn = nume1(y); on the Matlab OnRamp dosen't work ?<p>Task 1 ✔
fs=10</p><p>fs =
10</p><pre> Task 2 ✔
t=[0:1/fs:20];
Task 3 ✔
y = sin(1.8*2*pi*t)+sin(2.1*2*pi*t)</pre><pre> Task 4 ✔
plot(t,y,'r-')
Task 5 ✘</pre><pre> Task 5 ✔
yfft = fft(y)</pre><pre> Task 6 ✘
n = nume1(y)
Undefined function 'nume1' for input arguments of type 'double'.</pre><p>n = nume1(y);
Undefined function 'nume1' for input arguments of type 'double'.
Task 6 ✘
n = size(y)
n =
1 201
Task 6 ✘
N = nume1(y);
Undefined function 'nume1' for input arguments of type 'double'.</p>Babacar Dienghttps://de.mathworks.com/matlabcentral/profile/authors/10874729-babacar-diengtag:de.mathworks.com,2005:Question/3574492017-09-19T22:12:03Z2017-09-24T00:42:08ZHow to interpret ButtonDownFcn event data for axis which limit is datetime?<p>This seems like something obvious but I've searched for this all afternoon and can't come up with anything that addresses my issue.
I've been struggling with my buttondownfcn callback on an axes which xaxis is defined in datetime.</p><pre class="language-matlab">K>> ax.XAxis
</pre><pre class="language-matlab">ans =
</pre><pre> DatetimeRuler with properties:</pre><pre> Limits: [Aug 21, 2017, 21:00 Aug 21, 2017, 22:45]
TickValues: [Aug 21, 2017, 21:00 Aug 21, 2017, 21:15 Aug 21, 2017, 21:30 Aug 21, 2017, 21:45 Aug 21, 2017, 22:00 Aug 21, 2017, 22:15 Aug 21, 2017, 22:30 Aug 21, 2017, 22:45]
TickLabelFormat: 'HH:mm'</pre><pre> Show all properties</pre><p>The eventinformation comes in as</p><pre class="language-matlab">K>> eventdata
</pre><pre class="language-matlab">eventdata =
</pre><pre> Hit with properties:</pre><pre> Button: 1
IntersectionPoint: [0.927083313465118 5.139902343750000e+02 -1]
Source: [1×1 Axes]
EventName: 'Hit'</pre><p>I've read that is the "location of last button click, in axes data units", but the x value doesn't look like a datenum. I thought it might be an offset from the axis limit but</p><pre class="language-matlab">K>> ax.XLim(1)+eventdata.IntersectionPoint(1)
</pre><pre class="language-matlab">ans =
</pre><pre> datetime</pre><pre> Aug 22, 2017, 19:14</pre><p>is not where I picked. I picked as closed to the 22:15 tick mark (in the attached image) as I could. It's close but there's an origin somewhere that I seem to be missing.</p><p>Can anyone shed some light on this?</p>Scott Senftenhttps://de.mathworks.com/matlabcentral/profile/authors/9979923-scott-senftentag:de.mathworks.com,2005:Question/3580722017-09-24T00:01:35Z2017-09-24T00:20:11ZHelp function for comments not working<p>Below is the script named ConeVol. After I saved the script and typed the statement of, help ConeVol, in the command window, I don't see the print out of the comments in %{ and %}. Can someone help me to understand why? Shouldn't help function print out all the help comments?</p><pre class="language-matlab">%{
Computes volume of a cone.
Creates variables radius and height.
Result is assigned to variable volume and displayed.
The script was written by Blaise Pascal
on the year 1660
%}
radius = 3; % Radius of circle at base of cone
height = 2; % Height from base to point at top of cone
volume = (1/3) * pi * radius * radius * height % Note: pi is built-in constant
</pre><p>Thank you,
- Lisa</p>Lisa Leehttps://de.mathworks.com/matlabcentral/profile/authors/10665705-lisa-leetag:de.mathworks.com,2005:Question/3570252017-09-17T02:51:08Z2017-09-24T00:15:26Zhow to plot solution of differential second order equation ?<p>i would like to plot "sol3" but i still have this matlab error :</p><pre class="language-matlab">"Error using plot
Conversion to double from sym is not possible."
</pre><pre class="language-matlab">eq=diff(y,t)/R+C*diff(y,t,2)+y/L==diff(i,t)
Dy = diff(y,t);
cond = [y(0)==0, Dy(0)==0];
sol=dsolve(eq,cond)
sol2=simplify(sol)
sol3=vpa(sol2,2)
T=0:0.001:4;
plot(T, sol3);
</pre>Zina Odflhttps://de.mathworks.com/matlabcentral/profile/authors/10951963-zina-odfltag:de.mathworks.com,2005:Question/3580642017-09-23T21:56:12Z2017-09-24T00:05:40ZHow to use quiver with equations in function?<p>I have defined several functions with equations like</p><pre class="language-matlab">function dZ = ODE(~,z)
x = z(1);
y = z(2);
dZ = [x+y;...
4*x-2*y];
end
</pre><p>These functions are used by other functions for solving etc. Now I want to do plotting with quiver but I don't figure out how to pass a function with equations as a parameter to quiver. It should look like this:</p><pre class="language-matlab">odehandle = str2func('ODE');
plot_vectorfield(odehandle);
</pre><pre class="language-matlab">function plot_vectorfield(odehandle)
[x,y]=meshgrid(-10:1:10,-10:1:10);
[dx,dy]=odehandle; %does not work!
quiver(x,y,dx,dy);
end
</pre><p>So the problem is obviously how to pass the u,v parameter to quiver. I would also like to know how to handle function defined equation systems with 3 equations with quiver. Thanks a lot!</p>Sam Finchhttps://de.mathworks.com/matlabcentral/profile/authors/11050200-sam-finchtag:de.mathworks.com,2005:Question/3580732017-09-24T00:04:45Z2017-09-24T00:06:36ZHow to get eqns datatype from equations in function?<p>I can use functions like <b>A = equationsToMatrix(eqns)</b> with a direct <b>eqns</b> input parameters, e.g.</p><pre class="language-matlab">A = equationsToMatrix([x+y,4*x-2*y]);
</pre><p>but when storing several equation systems in functions like</p><pre class="language-matlab">function dZ = ODE(~,z)
x = z(1);
y = z(2);
dZ = [x+y;...
4*x-2*y];
end
</pre><p>I need a reference to the equations in the function so that i could use stg. like</p><pre class="language-matlab">A = equationsToMatrix([oderef(1),oderef(2)]); %does not work!
</pre><p><b>oderef(1)</b> and <b>oderef(2)</b> must stand for the 2 equations defined in my function ODE and must be of datatype <b>eqns</b> so that <b>equationsToMatrix</b> can accept these as a parameter. How do I do that? Thanks.</p>Sam Finchhttps://de.mathworks.com/matlabcentral/profile/authors/11050200-sam-finchtag:de.mathworks.com,2005:Question/3580712017-09-23T23:44:48Z2017-09-23T23:44:48ZHow to register points by using iterative closest point (ICP) between two 3D models?<p>Hello.</p><p>I have two 3D models and I want to register the points between these two models. How can I do that by using iterative closest point (ICP)? Thank you.</p>Zaitul Asyikin Aznanhttps://de.mathworks.com/matlabcentral/profile/authors/6899956-zaitul-asyikin-aznantag:de.mathworks.com,2005:Question/3580572017-09-23T20:17:05Z2017-09-23T23:36:23ZPlot function variables for each iteration in fmincon<p>Hi,</p><p>I am trying to plot the variables values calculated for each iteration in fmincon. @optimplotx give histogram plot but i want to plot separately each variable for my function. I am able to plot for each function evaluation, but i want the variable values to be plotted for each iteration just like @optimplotfcn.</p>Suvrat Ramasubramanianhttps://de.mathworks.com/matlabcentral/profile/authors/9173228-suvrat-ramasubramaniantag:de.mathworks.com,2005:Question/3580562017-09-23T20:11:37Z2017-09-23T23:02:49ZSolve differential equation with anonymous functions<p>Hello, everyone. I am already quite familiar when it comes to the resolution of differential equations(DE’S) in MATLAB with “ode45” function. I have already solved this problem by making a function dFdV that contained the DE’S which has as inputs (V,F), being V the independent and F the dependent variable.</p><pre class="language-matlab">function dFdV=funcion(V,F)
</pre><pre class="language-matlab">CTo=0.286;
</pre><pre class="language-matlab">k=0.4;
</pre><pre class="language-matlab">FT=F(1)+F(2)+F(3); % FT=FA+FB+FC;
</pre><pre class="language-matlab">CA=(CTo*F(1))/FT;
</pre><pre class="language-matlab">rA=-k*CA^2;
</pre><pre class="language-matlab">rB=-rA;
</pre><pre class="language-matlab">rC=-0.5*rA;
</pre><pre class="language-matlab">dFdV=zeros(3,1);
</pre><pre class="language-matlab">dFdV(1)=rA;
</pre><pre class="language-matlab">dFdV(2)=rB;
</pre><pre class="language-matlab">dFdV(3)=rC;
</pre><pre class="language-matlab">end
</pre><p>What I now want is to solve the same problem creating an anonymous function that contains the DE’S and using again “ode45” to solve them.</p><pre class="language-matlab">CTo=0.286;
</pre><pre class="language-matlab">k=0.4;
</pre><pre class="language-matlab">FT=@(F)(F(1)+F(2)+F(3)); % FT=FA+FB+FC;
</pre><pre class="language-matlab">CA=@(F)((CTo*F(1))/FT(F));
</pre><pre class="language-matlab">rA=-k*(CA(F))^2;
</pre><pre class="language-matlab">rB=-rA;
</pre><pre class="language-matlab">rC=-0.5*rA;
</pre><pre class="language-matlab">dFdV=@(V,F)[rA;rB;rC];
</pre><p>The problem is that when executing It pops up this message (“Undefined function or variable 'F'), which is obvious because now my function dFdV depends on V and F, but F has not been defined (as an input) as the former case.</p><p>What should I do?. Thanks</p>Walter Sanchezhttps://de.mathworks.com/matlabcentral/profile/authors/11049859-walter-sancheztag:de.mathworks.com,2005:Question/3577952017-09-21T19:58:07Z2017-09-23T22:56:31Zshowing strings of text in heatmap (R2017a) images<p>I would like to use the heatmap function that is newly available in Matlab R2017a to display information that may be either numbers or a string or text. For example, perhaps the first row might display in each square "n/a" and then other squares display numbers.</p><p>There is a Matlab <a href = "https://www.mathworks.com/examples/matlab/community/19655-heatmap-examples">heatmap example document</a> that demonstrates doing such a thing, but I cannot get it to work for the data I am working on. It appears that the example is tied to the heatmap function as found previously in the bioinformatics toolbox.</p><p>So - I'm wondering if anyone has suggestions for how to display strings in the boxes in images created using the new heatmap function available in Matlab R2017a. Thank you.</p>HWhttps://de.mathworks.com/matlabcentral/profile/authors/2390773-hwtag:de.mathworks.com,2005:Question/3580692017-09-23T22:46:18Z2017-09-23T22:53:05ZCreating dummy variables from categorical variable<p>Suppose there is a column vector array n containing unique but repeating values of the form</p><pre class="language-matlab">1
1
5
7
7
</pre><p>The aim is to create a matrix D which contains in its columns dummy variables for each unique value in n of the form</p><pre class="language-matlab">1 0 0
1 0 0
0 1 0
0 0 1
0 0 1
</pre><p>I use the following code:</p><pre class="language-matlab">uniq = unique(n);
N_obs = size(n,1);
N_ind = size(uniq,1);
D = NaN(N_obs,N_ind);
D(:,1) = n == uniq(1,1);
D(:,2) = n == uniq(2,1);
D(:,3) = n == uniq(3,1);
</pre><p>This produces the desired D matrix. However, it is tedious to write the last three lines so I wanted to use a for loop of the form</p><pre class="language-matlab">for i = N_ind
D(:,i) = n == uniq(i,1);
end
</pre><p>But this gives</p><pre class="language-matlab">NaN NaN 0
NaN NaN 0
NaN NaN 0
NaN NaN 1
NaN NaN 1
</pre><p>Where is my mistake in the loop?</p>Snoopyhttps://de.mathworks.com/matlabcentral/profile/authors/1754528-snoopytag:de.mathworks.com,2005:Question/3580702017-09-23T22:52:49Z2017-09-23T22:52:49Zi am confused of how to use gradient and contourf command on the matrix<p>i already had a text file. and I know how to read it into the matlab, but i am not sure how to use the gradient and contourf commands
from the textfile that i uploaded (x,y,u,v) where u and v are the velocities, the questions are:
a) strian rate for the entire flow filed. Use a gradiant MATLAB funcion to compute the velocity gradients. the output should be filled contour plot if the whole flow domain. Use contorf function to acheive this
b) Vorticity of the entire flow filed using equaton gradients from rotation tensor. present a filled contiur plot</p>yousef albahhttps://de.mathworks.com/matlabcentral/profile/authors/10851784-yousef-albahtag:de.mathworks.com,2005:Question/3580622017-09-23T21:40:06Z2017-09-23T22:44:58ZEdge transparency "EdgeAlpha" of a patch<p>Is it somehow possible to specify the edge transparency for the edges of a patch separately for each edge at a time?!?! ... I have a problem where I need to make one or more edges transparent in some patches ...</p><p>Thanks for the answer in advance!</p><p>Best Regards,</p><p>Ahmed Hossam</p>Ahmed Hossamhttps://de.mathworks.com/matlabcentral/profile/authors/2625160-ahmed-hossamtag:de.mathworks.com,2005:Question/2166962015-05-14T14:57:44Z2017-09-23T22:23:53ZCommand Window gone crazy ( scrolls on it's own )<p>My command window has lost its mind.
It behaves normally but after I type some commands and get some output, the command window automatically scrolls up until I can't see what I just typed. The only way out is to type clc. But even that doesn't completely help.I tried typing "home" but that seems to have made things worse (I <b>think</b> it's now scrolling to a different position... or something).</p><p>How can I get back to normal?
I checked all the Matlab preferences and... nuttin!</p><p>Help?</p><p>Dan</p>Danhttps://de.mathworks.com/matlabcentral/profile/authors/13437-dantag:de.mathworks.com,2005:Question/3580432017-09-23T15:04:22Z2017-09-23T22:16:29ZResizing a 3D image without using imresize3<p>I do not have the image processing toolbox on my MatLab 2016b so I cannot use the imresize3() function. Is there other ways to resize an image of (x,y,z) to (a,b,c)?</p>Penemoniehttps://de.mathworks.com/matlabcentral/profile/authors/7343218-penemonietag:de.mathworks.com,2005:Question/3580392017-09-23T13:59:18Z2017-09-23T22:14:41ZERROR: MATLAB R2017a cannot run RTI Connext Shapes Demo<pre class="language-matlab">DDS.import('ShapeType.idl','matlab', 'f')
Warning: DDS.Utilities.getRtiPaths: Unable to obtain mex compiler info. rtiddsgen preprocessor is being disabled. To correct, run mex -setup
> In DDS.Utilities.getRtiPaths
In DDS.Utilities.convertIDLtoXML
In DDS.import
INFO com.rti.ndds.nddsgen.Main Running rtiddsgen version 2.5.0, please wait ...
INFO com.rti.ndds.nddsgen.Main Done
</pre><pre class="language-matlab">Error using DDS.Utilities.convertDDStoMathWorksType
DDSType: int32
</pre><pre class="language-matlab">Error in DDS.internal.readTypesXML.Member
</pre><pre class="language-matlab">Error in DDS.internal.readTypesXML.Struct
</pre><pre class="language-matlab">Error in DDS.internal.readTypesXML.readTypesXML/readType
</pre><pre class="language-matlab">Error in DDS.internal.readTypesXML.readTypesXML
</pre><pre class="language-matlab">Error in DDS.import
</pre>Humza Walihttps://de.mathworks.com/matlabcentral/profile/authors/7869810-humza-walitag:de.mathworks.com,2005:Question/3580672017-09-23T22:11:07Z2017-09-23T22:14:16ZCallback Function for update plot with multiple functions<p>Hi, I need the slider bar to adjust all three of the functions on the plot, but I don't know how to make a callback to update it. Plot picture is attached and c</p><img src = "/matlabcentral/answers/uploaded_files/88822/Screen%20Shot%202017-09-23%20at%205.05.01%20PM.png"><p>ode is here:</p><pre class="language-matlab">% 3.131
</pre><pre class="language-matlab">k = 180; %W/m K
L = 10e-3; %m
t = 1e-3; %m
Tb = 100 + 273; %K
Tinf = 25 + 273; %K
h = linspace(10,1000,20);
</pre><pre class="language-matlab">m = sqrt(2 .* h ./ (k * t));
M = sqrt(2 .* h .* t .* k) .* (Tb-Tinf);
</pre><pre class="language-matlab">qfa = M .* (sinh(m .* L)+(h ./ (m .* k)) .* cosh(m .* L)) ./ (cosh(m .*L) + (h ./ (m .*k)).*sinh(m.*L));
</pre><pre class="language-matlab">qfb = M .* tanh(m.*L);
</pre><pre class="language-matlab">qfd = M;
</pre><pre class="language-matlab">f = figure;
</pre><pre class="language-matlab">plot(h,qfa,'k','DisplayName','qfa'); hold on;
plot(h,qfb,'b','DisplayName','qfb');
plot(h,qfd,'r','DisplayName','qfd');
xlabel('Convection coefficient, h(W/m^2 * K)'); ylabel('Heat rate,qf(W/m)'); title('Heat rate vs h for different boundary conditions');
legend('show')
</pre><pre class="language-matlab">b = uicontrol('Parent',f,'Style','slider','Position',[81,54,419,50],...
'value',k,'min',15,'max',180);
bgcolor = f.Color;
bl1 = uicontrol('Parent',f,'Style','text','Position',[50,54,23,50],...
'String','15','BackgroundColor',bgcolor);
bl2 = uicontrol('Parent',f,'Style','text','Position',[500,54,23,50],...
'String','180','BackgroundColor',bgcolor);
bl3 = uicontrol('Parent',f,'Style','text','Position',[240,50,100,40],...
'String','Conduction Coefficient, k(W/m K)','backgroundColor',bgcolor);
</pre>Maxsam Dontahttps://de.mathworks.com/matlabcentral/profile/authors/7253226-maxsam-dontatag:de.mathworks.com,2005:Question/3580222017-09-23T10:32:50Z2017-09-23T22:05:39ZHow to remove artifacts from a signal<p>Hello,</p><p>I would like to remove artifacts from a signal, typically a lack of information in a thermocouple signal due to a shortcut.
In fact I don't want to calculate the moving average because it would alter the "good information" and extrapolate data that don't exist. But I want to detect wrong information (artifacts) based on this moving average, and replace it by NaN or 0.</p><img src = "/matlabcentral/answers/uploaded_files/88794/Capture.PNG"><p>I tried to code it, but it is not efficient at all (based on for loops), and I am sure I am not the first one to do this ;)</p><p>Thanks a lot for your help!</p><p>Max</p>maxroucoolhttps://de.mathworks.com/matlabcentral/profile/authors/2077384-maxroucooltag:de.mathworks.com,2005:Question/3580662017-09-23T22:04:06Z2017-09-23T22:04:06ZAppend Data to New Dimensions of Variable in NetCDF File<p>I am working on reading in multidimensional variables (time, lat, lon) from one NetCDF file as single vectors (along the time dimension), performing some computations, and would like to write them out to a new NetCDF file with the same structure but I cannot find any documentation that is clear enough to assure me I would be writing the columns back to their exact locations as in the original NetCDF. My transformations change the data values in the individual variables but not the length of any of their respective dimensions so it would be possible to state from the outset the size of each dimension.</p><p>My question is fairly similar to <a href = "https://www.mathworks.com/matlabcentral/answers/335105-how-to-create-a-netcdf-file-with-a-multidimensional-variable-in-matlab">this one</a> but in that case the user is trying to append entire three-dimensional matrices. In my case the transformations I am applying require single vectors and I run the risk of maxing out my memory if I retain the entire 3D matrix prior to writing to disk.</p>Ryanhttps://de.mathworks.com/matlabcentral/profile/authors/3640757-ryantag:de.mathworks.com,2005:Question/3580652017-09-23T22:01:14Z2017-09-23T22:01:14ZHow to convert a simpower system network into a graph with nodes and edges <p>Hi,
I've modeled a power system via simpowersystems and want to convert this electrical network into a matlab graph with nodes and edges. My idea is to know what electrical component is connected to which node so that to use this information in an algorithm.
Please advice.</p>Djibril DIOPhttps://de.mathworks.com/matlabcentral/profile/authors/10966629-djibril-dioptag:de.mathworks.com,2005:Question/3579802017-09-22T20:27:57Z2017-09-23T21:50:52ZAny guidance how to solve this, really need this and will be grateful for any help.<pre class="language-matlab">clc
clear all
syms y
a = 0:0.5:10;
U = 1;
x= 0;
sym y
for m = 0:1:10
j = 1;
eqn = U*y -(m/(2*pi)*atan((2*a*y)/(x.^2 + y.^2 - a.^2)))== 0;
soly = solve(eqn,y);
Y(j,1) = double(soly);
j = j + 1;
end
</pre><p>I need to get values for y or solve the eqn for y</p>Shifohttps://de.mathworks.com/matlabcentral/profile/authors/10835987-shifotag:de.mathworks.com,2005:Question/3580602017-09-23T21:15:03Z2017-09-23T21:50:08ZI need the matlab code for wsn using genetic algorithm<p>I need the matlab GA simulation of wsn</p>louisa ogushahttps://de.mathworks.com/matlabcentral/profile/authors/10701762-louisa-ogushatag:de.mathworks.com,2005:Question/3579942017-09-23T00:13:19Z2017-09-23T21:48:25ZPerimeter used by regionprops<p>Hi all,</p><p>I am using the output of bwconncomp as an input to regionprops to calculate some values for blobs in a binary image. One of the values that I calculate is "solidity" which is a direct output of regionprops. However, I am also interested in calculating circularity, which I define as 4*pi*Area/Perimeter^2. However, I keep getting values that are greater than one, which is unexpected. From running bwconncomp and regionprops on some artificial binary images with some pixels arbitrarily set to 1 to represent particles I can tell that regionprops does not calculate perimeter in the way that I would normally think of it. Does anybody know if the perimeter calculation fails for very small clusters of "on" pixels, or is there some rationale behind what regionprops is doing, and I just don't understand it?</p><p>I'll post the code I use to troubleshoot this:</p><pre class="language-matlab">%make an empty matrix
a = zeros(5,5)
</pre><pre class="language-matlab">%put a small cross shaped particle onto it
a(2, 2:4) = 1
a(1:3, 3) = 1
</pre><pre class="language-matlab">%call bwconncomp
cc = bwconncomp(a)
</pre><pre class="language-matlab">%call regionprops
blobFacts = regionprops(cc, 'Perimeter', 'Solidity', 'Area')
</pre><pre class="language-matlab">%report values
p = blobFacts.Perimeter
s = blobFacts.Solidity
a = blobFacts.Area
</pre><pre class="language-matlab">%manually calculate circularity
c = (4*pi*a)/p^2
</pre><p>This gives a circularity of 1.9865, which is higher than 1 (what I intuitively think of as the max possible circularity). The area of the particle is 5, which is expected, but the perimeter is 5.6240, and I can't seem to figure out how regionprops is getting that value. Thanks in advance,</p><p>Clay</p>Clay Swackhamerhttps://de.mathworks.com/matlabcentral/profile/authors/5344591-clay-swackhamertag:de.mathworks.com,2005:Question/3580012017-09-23T01:34:30Z2017-09-23T21:37:58ZWhy am I not getting different values for the absolute value percent error?<p>The question that is in the textbook that I have states:</p><p>The infinite series converges on a value of f (n) = π4/90 as n approaches infinity. Write a program in single precision to calculate f (n) for n = 10,000 by computing the sum from i = 1 to 10,000. Then
repeat the calculation but in reverse order—that is, from i = 10,000 to 1 using increments of −1. In each case, compute the true percent relative error. Explain the results. The bottom image is the series.</p><img src = "/matlabcentral/answers/uploaded_files/88770/GLzjo.png"><p>My code that I have gives the exact same error values for forwards and backwards. :( What is wrong with my code?</p><pre> clear
clc
while (1)
tru = ((pi^4)/90);
p = input('Enter number of iterations (n): ' );
for i = 1:p
y(i+1) = 1/(i^4);
end
z = sum (y);
disp ('The approximation value is ');
disp (z);
absval = ((tru - z)/tru);
disp ('The absolute value percent error from 1 to 10000 is ');
disp (absval);
for i = p:-1:1
y2(i+1) = 1/(i^4);
end
z2 = sum(y2);
disp ('The approximation value backwards is ');
disp (z2)
absval2 = ((tru - z2)/tru);
disp ('The absolute value percent error from 10000 to 1 is ');
disp (absval2);
m = input('Do you want to continue, Y/N [Y]:','s');
if m == 'N';
break
elseif m == 'n';
break
end
end</pre>Peter Phunghttps://de.mathworks.com/matlabcentral/profile/authors/10974036-peter-phungtag:de.mathworks.com,2005:Question/3580522017-09-23T19:05:53Z2017-09-23T21:19:59ZIs there a list of MATLAB Runtime dependencies?<p>Greetings,</p><p>I was deploying the <a href = "https://www.mathworks.com/products/compiler/mcr.html">MATLAB Runtime (aka MCR)</a> to a headless Redhat Enterprise Linux (RHEL) 7.4 environment when I noticed that I was missing several dependencies.</p><p>I installed MCR version R2017b (9.3) with this command (which succeeded, see install.txt):</p><pre class="language-matlab">./install -mode silent -agreeToLicense yes
</pre><p>I then set / verified the LD_LIBRARY_PATH environment variable:</p><pre class="language-matlab">$ echo $LD_LIBRARY_PATH
:/usr/local/MATLAB/MATLAB_Runtime/v93/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v93/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v93/sys/os/glnxa64:
</pre><p>Finally, I tested the Shared Object files included in the installation to verify they have available all the libraries they need:</p><pre class="language-matlab">find /usr/local/MATLAB -type f -name '*.so*' -exec ldd {} \; | grep 'not found' | sort | uniq
</pre><p>This resulted in the libraries listed in the attached notFound.txt. While I can easily determine which packages provide these libraries with Yellowdog Updater, Modified (yum) and install them, was wondering (especially for future deployments of future versions) if there exists a list of packages for supported Linux distributions that need to be deployed alongside the MCR. I checked the <a href = "https://www.mathworks.com/help/compiler/install-the-matlab-runtime.html">MCR Documentation</a> and didn't see a list of said libraries.</p><p>Thanks</p>Nicholas Haashttps://de.mathworks.com/matlabcentral/profile/authors/11047956-nicholas-haastag:de.mathworks.com,2005:Question/3580302017-09-23T12:08:30Z2017-09-23T21:18:03Zhow to read grid data from text file ?<p>hi
I have a text file(attached). which contain ozone data. I am not able to read the data. since it is not in regular format. only latitude(-59.5S to 59.5N (1.00 degree steps)
) is given and on every latitude all ozone data is given so there are 288 longitudes(-179.375W to 179.375E (1.25 degree steps)) therefore 288 data points are there. but the problem is all data is in string format and we need to split data after every 3 digit. some random space is also given in the middle of the data so we have to remove that also otherwise data will not split in 3 correct digits .</p><p>later i will use inpolygon to grab out the data from specific region. that i will try later. but first i need to read this text file and took the data out.</p><p>hope you understand.</p>pruthhttps://de.mathworks.com/matlabcentral/profile/authors/6973195-pruthtag:de.mathworks.com,2005:Question/3580452017-09-23T16:08:18Z2017-09-23T21:15:29ZEqualizing Images for Background Subtraction<p>Hi;</p><p>I have a microscopic image of sperm and also the background of the image. I want to subtract them and then segment the sperms, but the two images are not equal in brightness and contrast, therefore some unwanted parts remain in the result. How can I equalize them? I used "histeq" and "adapthisteq" but the result was not good.</p><p>The images are attached.</p><p>Thank You :)</p><img src = "/matlabcentral/answers/uploaded_files/88810/matlab%20answers.jpg">Peyman Ghasemihttps://de.mathworks.com/matlabcentral/profile/authors/4395296-peyman-ghasemitag:de.mathworks.com,2005:Question/3573002017-09-19T05:49:10Z2017-09-23T21:09:54ZWhat is problem?<img src = "/matlabcentral/answers/uploaded_files/88375/search1.PNG"><p>I want to apply this code on another image, but i am getting this problem, and the image can not be shown.</p><img src = "/matlabcentral/answers/uploaded_files/88376/mathlab.PNG"><p>Please any help</p>Haseeb Hassanhttps://de.mathworks.com/matlabcentral/profile/authors/10023405-haseeb-hassantag:de.mathworks.com,2005:Question/3570122017-09-16T22:19:10Z2017-09-23T21:01:37Zwhat type of function, algorithm, formula, do i need to get/see the individual sinusoids <p>what type of function, algorithm, formula, do i need to get the individual sinusoids components of a complex wave, visually over time like a FFT spectrum analyzer, but the individual overlayed sinusoids over time like an occiliscope view, but with all the individual sinusoids displayed at the same time...like Mark huckvales E-synth ( <a href = "http://www.phon.ucl.ac.uk/resource/sfs/esynth.php">E-Synth</a>, here is an example of displaying sinusoids from Simulink sine wave blocks(4 of them), through a vector concatenate block and analyzing the signal at the end with logic analyzer app.. but it does not seem to do the same component display with a audio file or an in put from the audio device reader block. thanks for any help...peace hope love</p>Brent Cartwrighthttps://de.mathworks.com/matlabcentral/profile/authors/9371673-brent-cartwrighttag:de.mathworks.com,2005:Question/3580542017-09-23T19:22:19Z2017-09-23T20:58:12Zthis is my first time extracting eeg signal.for practising only beta wave is taken.after running my code there doesn't show any curve though no error is found.M1 is declared as variable help me to find the problem<pre class="language-matlab">load S001R01_edfm.mat;% loading data
Ts=2;% sampling period
Fs=500;%sampling frequency
[N,nu]=size(M1);%obtain size of data
t=(1:N)*Ts;%generates time vector
%% Raw Signal Analysis
figure()
title('EEG Wave Patterns')
subplot (2,1,1),plot(t,M1)
grid on;
xlabel('Time(s)')
ylabel('Amplitude')
title('Raw EEG Signal')
xlim([0 (1600)])
</pre><pre class="language-matlab">%BETA BANDPASS FILTER (12-30)
</pre><pre class="language-matlab">Fs = 500; % Sampling Frequency
</pre><pre class="language-matlab">Fstop1 = 11.5; % First Stopband Frequency
Fpass1 = 12; % First Passband Frequency
Fpass2 = 30; % Second Passband Frequency
Fstop2 = 30.5; % Second Stopband Frequency
Dstop1 = 0.0001; % First Stopband Attenuation
Dpass = 0.057501127785; % Passband Ripple
Dstop2 = 0.0001; % Second Stopband Attenuation
dens = 20; % Density Factor
</pre><pre class="language-matlab">% Calculate the order from the parameters using FIRPMORD.
[N, Fo, Ao, W] = firpmord([Fstop1 Fpass1 Fpass2 Fstop2]/(Fs/2), [0 1 ...
0], [Dstop1 Dpass Dstop2]);
</pre><pre class="language-matlab">% Calculate the coefficients using the FIRPM function
b4 = firpm(N, Fo, Ao, W, {dens});
Hd4 = dfilt.dffir(b4);
x4=filter(Hd4,M1);
subplot(2,1,2), plot(t,x4)
grid on;
xlabel('Time(s)')
ylabel('Amplitude')
title('BETA Waves')
xlim([0 (1600)])
title('waveform for BETA band')
</pre>tahia chowdhuryhttps://de.mathworks.com/matlabcentral/profile/authors/10405979-tahia-chowdhurytag:de.mathworks.com,2005:Question/3580582017-09-23T20:28:37Z2017-09-23T20:51:43ZHow to use subs to evaluate a symbolic matrix?<p>I am trying to evaluate the pseudo-inverse of a Jacobin matrix that was computed symbolically. I use the subs command to insert the values I wanted into the resulting matrix, but I'm running into trouble getting MATLAB to actually carry through the calculations. The result is just the matrix with the numbers in the place where the syms were earlier, the actual math still having not been carried out.</p><p>My code is as follows</p><pre class="language-matlab">q1 = 1.57; %inital angles
q2 = 1.57;
q3 = 1.57;
l1 = 2; %arm lengths
l2 = 1;
l3 = 2;
syms qa qb qc la lb lc
J = jacobian([qa+qb+qc, la*cos(qa) + lb*cos(qa+qb)+ lc*cos(qa+qb+qc),la*sin(qa) + lb*sin(qa+qb)+ lc*sin(qa+qb+qc)], [qa, qb , qc]); %Creating the jacobian matrix
Jinv = pinv(J);
Jinv_eval = subs(Jinv, [qa, qb, qc, la, lb, lc],[q1, q2, q3, l1, l2, l3]); %substituting in the numerical values I want
Jinv_eval = subs(Jinv_eval);
disp(Jinv_eval);
</pre><p>Am I missing a command to have MATLAB carry out the calculation after making the substitutions with the subs command, or is there something more insidious going on?</p>Montgomery Blairhttps://de.mathworks.com/matlabcentral/profile/authors/10366115-montgomery-blairtag:de.mathworks.com,2005:Question/3580552017-09-23T20:02:19Z2017-09-23T20:41:43ZProblem with printing exponents with multiple digits<p>Whenever I am trying to print an exponent with more than one digit, only the first digit is printed as an exponent, and the remaining digits are printed as a regular number.</p><p>Example Script:</p><pre class="language-matlab">x = [1 : 100];
y1 = x.^10;
</pre><pre class="language-matlab">plot(x', y1');
title("x vs x^10");
</pre><p>Output:</p><img src = "/matlabcentral/answers/uploaded_files/88816/Untitled.png"><p>The red rectangle shows the problem.</p><p>How do I print x^10?</p><p>-</p>Quazi Irfanhttps://de.mathworks.com/matlabcentral/profile/authors/9409472-quazi-irfantag:de.mathworks.com,2005:Question/3579852017-09-22T21:42:12Z2017-09-23T20:30:02ZHow to use an excel file to create entities in Simevents ?<p>I want to load the values of cycle time and entity type from excel in a Simevents model. What should be the basic simulink blocks to read this data to evaluate a Simevents model?
Regards.
Ralf</p>Rafa Juarezhttps://de.mathworks.com/matlabcentral/profile/authors/11034460-rafa-juareztag:de.mathworks.com,2005:Question/3580282017-09-23T11:35:56Z2017-09-23T19:55:22ZHow to plot this function ?<p>Hello all, I'm quite new to matlab , so I want to figure out how to plot that heaviside function ?</p><img src = "/matlabcentral/answers/uploaded_files/88801/f.PNG"><p>I want to get that graphic below the function.</p>Tomas Tyvhttps://de.mathworks.com/matlabcentral/profile/authors/11046426-tomas-tyvtag:de.mathworks.com,2005:Question/1027112009-06-27T01:12:00Z2017-09-23T19:39:28ZHow do I break out of nested loops using the BREAK command in MATLAB 7.7 (R2008b)?<p>I am trying to break out of nested FOR loops using BREAK, but the control returns to the loop immediately above.</p>MathWorks Support Teamhttps://de.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:de.mathworks.com,2005:Question/3580532017-09-23T19:14:05Z2017-09-23T19:35:54ZAdding Procrustes Code to a PCA<p>How do I add new instructions or code to an existing callback in a gui. I have a button that when I press in a GUI it performs a PCA for me. However I want to add Procrustes code so that any time I press that particular button in the GUI, PCA will be performed in addition to a Procrustes analysis. How do I add the Procrustes code to that part of the PCA code so that they communicate? Any code example?</p><p>Thank you.</p>Francis Kwofiehttps://de.mathworks.com/matlabcentral/profile/authors/8298095-francis-kwofietag:de.mathworks.com,2005:Question/3579912017-09-22T22:58:07Z2017-09-23T19:33:44ZWhat is the best way to go about integrating a discrete and evenly spaced dataset?<p>I am calculating a gas diffusional profile in a solid sphere for which the first and second derivatives of the curve are both negative. This causes a systematic bias such that linear interpolation/trapz causes volume calculation errors to rise asymptotically under certain circumstances. I have been told that Romberg integration is a good antidote to the problem, however, it appears that a requirement of the Romberg method is to have a smooth, continuous function. Unfortunately, this curve can not be described by such a function.</p><p>I am wondering if someone more skilled than myself could help me come up with an interpolation scheme (piecewise?) that would give me the continuous function that could be fed into a Romberg script.</p><p>I have also tried using <a href = "https://www.mathworks.com/matlabcentral/fileexchange/28726-simpson-s-rule-integration?focused=5186784&tab=function">Simpson's rule integration</a>, but it seems my implementation is causing significant errors as well. I am probably doing something stupid wrong, but I have been staring at this stuff too long to really even tell. The approach here is to calculate and add the volume contributed by the concentration in each sphere between two spatial nodes, where v is the height of the concentration curve at radial position r, j is the index for spatial nodes and n is the number of spatial nodes:</p><pre> vol = simpsons([v(1) v(1)],0,r(1),[]) * (4/3 * pi * r(1)^3);
for j = 2:n
vol = vol + (4/3 * pi * r(j)^3 * simpsons(v(1:j),0,r(j),[]) - vol);
end</pre><p>I am probably making a stupid mistake here, and I'm not too familiar with interpolation schemes in MATLAB, so any advice or help on either front is greatly appreciated.</p><p>I have also attached an example of one of the curves I am trying to integrate over. v is on the y-axis and r (fractional) is on the x-axis.</p><img src = "/matlabcentral/answers/uploaded_files/88763/helpcurve.png">Adam Goldsmithhttps://de.mathworks.com/matlabcentral/profile/authors/6114551-adam-goldsmithtag:de.mathworks.com,2005:Question/3580442017-09-23T15:08:05Z2017-09-23T19:27:59Zmatlab software free version ..... but why to pay it now ?<p>After opening matlab, I have found a message -"Matlab license will expire in 49 days. Please contact your system administrator or Mathworks to renew this license"... but I installed it's free version 3 years ago. then why I have to pay now to get it? Is this software does not run after 49 days or it shows any other meaning which I don't understand? please help me what I have to do to get it free .....</p>ARNAB CHATTARAJhttps://de.mathworks.com/matlabcentral/profile/authors/6269440-arnab-chattarajtag:de.mathworks.com,2005:Question/3580232017-09-23T10:39:53Z2017-09-23T19:15:22ZFaster / more precise logarithm of complimentary error function?<p>If there is a way to calculate the logarithm of complimentary error function with better numerical precision (and preferably also faster) than doing it in the straightforward manner, e.g.</p><pre class="language-matlab">log(erfc(-5:5))
ans =
0.6931 0.6931 0.6931 0.6908 0.6112 0 -1.8496 -5.3649 -10.7204 -17.9878 -27.2009
</pre><p>As far as I know, many of numerical approximations involve product that includes exponential in some form <a href = "https://en.wikipedia.org/wiki/Error_function#Approximation_with_elementary_functions">e.g. see Wikipedia</a>, so it feels that some potential gain could be achieved through it.</p>Gleb Tikhonovhttps://de.mathworks.com/matlabcentral/profile/authors/7808020-gleb-tikhonovtag:de.mathworks.com,2005:Question/1519002014-08-22T05:55:20Z2017-09-23T19:06:49Z in Regard of Feval error<p>hi</p><p>i have come across the following error -</p><pre class="language-matlab">Error using feval
Undefined function 'viewpm_Callback' for input arguments of type 'struct'.
</pre><pre class="language-matlab">Error in gui_mainfcn (line 96)
feval(varargin{:});
</pre><pre class="language-matlab">Error in radar_waveform_analyzer_18july (line 42)
gui_mainfcn(gui_State, varargin{:});
</pre><pre class="language-matlab">Error in @(hObject,eventdata)radar_waveform_analyzer_18july('viewpm_Callback',hObject,eventdata,guidata(hObject))
</pre><pre> Error while evaluating uicontrol Callback</pre><p>when i go to callback function of viewpm( pop-up menu in gui) i get no code for dat, however the concerned code is elsewhere in .m file.
although i m able to run the gui , but its functionality has been changed.
i am also attaching .m code file.</p><p>pls contribute and resolve.</p><p>Thanks and Regards,</p><p>Rahul sharma</p>rahulhttps://de.mathworks.com/matlabcentral/profile/authors/5497732-rahultag:de.mathworks.com,2005:Question/3580512017-09-23T18:55:39Z2017-09-23T19:04:56ZCan I download the pdf dcumentation. I have tried the online help and I really do not like it. I would appreciate it if I could have updated pdf dcoumentation for my newest release installation (R2017a<p>Can I download the pdf documentation? I have tried the online help and I really do not like it. I would appreciate it if I could have updated pdf documentation for my newest release, installation (R2017a)?</p>George Boukarimhttps://de.mathworks.com/matlabcentral/profile/authors/520858-george-boukarimtag:de.mathworks.com,2005:Question/2551442015-11-16T16:24:33Z2017-09-23T18:44:34ZHow to generate a point cloud in 3D?<p>Hello dear community,</p><p>I would like to know if there is a fast way to create a cloud in 3D which consists of points. I would like to get something like this:</p><img src = "/matlabcentral/answers/uploaded_files/40299/image015.jpg"><p>The points should be written into a simple matrix. Each row should represent one point.
Thank you for your help!</p>Leo Müllerhttps://de.mathworks.com/matlabcentral/profile/authors/7251449-leo-mullertag:de.mathworks.com,2005:Question/3580462017-09-23T16:41:02Z2017-09-23T18:37:29ZShould I indicate no input arguments to a function?<p>Suppose I have a function which requires no inputs. Should I indicate it with parentheses () or leave it naked? Both cases work, but is there a convention in the MATLAB community?</p><p>Example:</p><pre class="language-matlab">someFunction
% do sth
end
</pre><p>vs</p><pre class="language-matlab">someFunction()
% do sth
end
</pre>Zoltán Csátihttps://de.mathworks.com/matlabcentral/profile/authors/2924415-zoltan-csatitag:de.mathworks.com,2005:Question/3580472017-09-23T17:04:10Z2017-09-23T18:33:53Zreshape a matrix from the text<p>I am trying to reshape a matrix from the text file to 45x50 , but when i do the reshape it shows that the number of the elements should not be changes. is there any problem with my coding?</p><pre> % fileid = fopen ('2016 Sept 7 - Vortex 1_0001')
x = textscan (fileid, '%n %n %n %n','headerlines',3,'delimiter',',')
cc = reshape (x, 44,45)</pre>yousef albahhttps://de.mathworks.com/matlabcentral/profile/authors/10851784-yousef-albahtag:de.mathworks.com,2005:Question/2926002016-06-28T07:21:09Z2017-09-23T18:23:19ZError using eval undefined function 'workspacefunc' for input arguments of type 'struct'<p>Hello,</p><p>I'm using MATLAB2014b version and it was working well till yesterday. But, then I install Robotics Toolbox and add the path for it. So, now when I started it show error like this in dialogue box</p><p>Error using eval undefined function 'workspacefunc' for input arguments of type 'struct'</p><p>I have read many answers like</p><p>(1) <a href = "http://in.mathworks.com/matlabcentral/answers/91560-why-do-i-receive-error-using-eval-when-i-start-matlab">http://in.mathworks.com/matlabcentral/answers/91560-why-do-i-receive-error-using-eval-when-i-start-matlab</a></p><p>but my matlab shows only one file named <i>pathdef.m</i> like below</p><pre> >> which -all pathdef
C:\Program Files\MATLAB\R2014b\toolbox\local\pathdef.m
>> </pre><p>(2) <a href = "http://in.mathworks.com/matlabcentral/answers/195599-error-starting-matlab-r2015a">http://in.mathworks.com/matlabcentral/answers/195599-error-starting-matlab-r2015a</a></p><p>I changed the ownership to everyone but problem was still there.</p><p>I also tried <i>restoredefaultpath</i> command but it shows error like this</p><pre> >> restoredefaultpath
Error: File: restoredefaultpath.m Line: 32 Column: 62
Unexpected MATLAB operator.</pre><p>Can anybody help me to resolve this issue.</p>NASEEB SINGHhttps://de.mathworks.com/matlabcentral/profile/authors/7431288-naseeb-singhtag:de.mathworks.com,2005:Question/3580502017-09-23T18:04:32Z2017-09-23T18:14:26Z"Function definitions are not permitted in this context." ? bisection<p>I am really new to MATLAB. I'm trying to write/test a bisection program that determines T as a function of C. I have initial guesses and will test some cases in the command window, but my code doesn't execute. I'm getting this error on the first line: "Function definitions are not permitted in this context." I'm not really sure if it's a file type error or a syntax error and how to fix it. Some help would be appreciated.</p><p>Thanks!</p><pre class="language-matlab">function [TofC] = TEval(osf)
</pre><pre> % temp absolute
U = 40+273.15;
L = 0+273.15;</pre><pre> % disp if no bracketing for a guess
if 0 < fTabs(L,osf)*fTabs(U,osf)
error('brackets')
end
end</pre><pre> r = L;</pre><pre> %iterate 1 to 10
for i=1:10
rInitial=r;
r = 0.5*(L+U);
% middle val
if r~=0, z = 100 * abs((r-rInitial)/r);
end
%check specifies test values from text
check=fTabs(r,osf)*fTabs(L,osf);
if check < 0
U = r;</pre><pre> elseif check > 0
r = L;</pre><pre> else
z = 0;
end
end</pre><pre> TofC = -273.15 + r; </pre><pre> function [k] = fTabs(Tabs,osf)
k = -139.3441 + ((1.5757e5)/Tabs) - ((6.64231e7)/Tabs^2);
k = k - ((8.62195e11)/Tabs^4) + ((1.2438e10)/Tabs^3);
k = k - log(osf);
end</pre>Amanda Padillahttps://de.mathworks.com/matlabcentral/profile/authors/10721877-amanda-padillatag:de.mathworks.com,2005:Question/3580492017-09-23T17:37:59Z2017-09-23T18:05:49ZHow do I do this switch statement?<p>How do I do this?</p><img src = "https://www.mathworks.com/matlabcentral/answers/uploaded_files/88812/image.png">Blair Hallhttps://de.mathworks.com/matlabcentral/profile/authors/10774882-blair-halltag:de.mathworks.com,2005:Question/3579982017-09-23T00:53:09Z2017-09-23T17:06:49Zif i have a matrix of x,y,u,v how can i use the gradient command<p>how to use the gradient</p>Ameed Azarhttps://de.mathworks.com/matlabcentral/profile/authors/10846826-ameed-azar