https://www.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2017-09-24T14:05:35Ztag:www.mathworks.com,2005:Question/3579942017-09-23T00:13:19Z2017-09-24T14:05:35ZPerimeter 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://www.mathworks.com/matlabcentral/profile/authors/5344591-clay-swackhamertag:www.mathworks.com,2005:Question/3581122017-09-24T14:05:06Z2017-09-24T14:05:06ZThe Bisection Method Function<p>I am trying to write an function that calculates the zero of a given function using the The Bisection Method. But I can't get it to work and need help to see what's wrong in my code. Any help appreciated!</p><pre class="language-matlab">function m=m_bisect(f,I,tol)
</pre><pre> % Example-input x = m_bisect(@(x)cos(x),[1,2],1e-5)
a=I(1);
b=I(2);</pre><pre> if f(a)*f(b) > 0
disp('Wrong input, try again');
m=[];
return
else
m=(a+b)/2;
fromZero = abs(f(m));
while fromZero > tol
if f(a)*f(m) < 0
b = m;
else
a = m;
m=(a+b)/2;
fromZero = abs(f(m));
end
end
end</pre>Oskar Verteticshttps://www.mathworks.com/matlabcentral/profile/authors/10972791-oskar-verteticstag:www.mathworks.com,2005:Question/3580672017-09-23T22:11:07Z2017-09-24T14:02:48ZCallback 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://www.mathworks.com/matlabcentral/profile/authors/7253226-maxsam-dontatag:www.mathworks.com,2005:Question/3568762017-09-15T17:03:58Z2017-09-24T14:01:49ZHow to solve f(X)=0 if X is a symbolic matrix and 0 is the null matrix? <p>How to solve f(X)=0 if X is a symbolic matrix and 0 is the null matrix?
Thanks!</p>Massa Ndonghttps://www.mathworks.com/matlabcentral/profile/authors/10427602-massa-ndongtag:www.mathworks.com,2005:Question/3581052017-09-24T12:41:01Z2017-09-24T14:01:19ZIs MATLAB a compiler?<p>I have been using MATLAB for some time but I am still not clear how MATLAB compares to some alternative software in the following respect. One of these software is Fortran. Some people claim that their optimisation algorithm works (much) faster in Fortran than in MATLAB or in R. When I ask why, the answer I get is that MATLAB is a compiler. What does this mean? What is that MATLAB is compiling and Fortran is not? And if it is indeed true that MATLAB is slower in some optimisation algorithm, compared to Fortran, what exactly is causing this?</p>Snoopyhttps://www.mathworks.com/matlabcentral/profile/authors/1754528-snoopytag:www.mathworks.com,2005:Question/3581022017-09-24T12:11:18Z2017-09-24T14:00:41ZImport an Excel File<p>Hi,</p><p>I have given an Excel table.
This Excel table I have imported with "Import Data" and saved as a cell array as "generate function".
Now I want to asign the content of the imported file to a variable. Can I do that with:
imp = importfile_1(file path of the created import file);</p><p>The problem is that it doesn't work atm.
The entries in the variable are not equal to the excel entries.</p><p>At the end I want to have a two dimensional array with the entries of the Excel file.</p><p>I hope one of you can help me.</p>mb12345https://www.mathworks.com/matlabcentral/profile/authors/10479199-mb12345tag:www.mathworks.com,2005:Question/3581042017-09-24T12:36:22Z2017-09-24T13:57:58Zfile selection gui element<p>I have been searching a while now.. but I can't seem to find a simple file selection GUI element, to put in my own GUI.</p><p>Is there such a thing as a file selection GUI element?</p>Thijs Schramahttps://www.mathworks.com/matlabcentral/profile/authors/8824301-thijs-schramatag:www.mathworks.com,2005:Question/3580892017-09-24T07:19:16Z2017-09-24T13:54:27Zhow to solve imread() issues?<img src = "/matlabcentral/answers/uploaded_files/88835/Capture.PNG">benjamin123https://www.mathworks.com/matlabcentral/profile/authors/10785271-benjamin123tag:www.mathworks.com,2005:Question/3580732017-09-24T00:04:45Z2017-09-24T13:52:54ZHow to get eqns datatype from equations in function?<p>I can use functions like <b>A = equationsToMatrix(eqns)</b> with 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 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 it 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://www.mathworks.com/matlabcentral/profile/authors/11050200-sam-finchtag:www.mathworks.com,2005:Question/3539102017-08-24T11:12:13Z2017-09-24T13:48:56ZQuadprog - variable values zero or higher than particular value<p>Hello,</p><p>I am trying to use quadprog in Matlab to solve quadratic problem with particular constraints. Here are they:</p><p>1.) x has to be weights vector, so sum of x has to be 1. This includes also constraint, that all values of x have to be from interval (0,1), including 0</p><p>2.) x * vector1 = particular value. (vector1 is known, and particular value is set in constraint)</p><p>Everything works great and setting constraints wasn't that hard.... but my vector x contains approximately 6000 variables. That makes values of almost all of those variables to be less than 10^-4. I would like to make them zero or higher than some value (for example 0.01). Is it possible? Right now, if I extract 20 most biggest values and make new weight vector depending on sum of their values from result of quadprog, second constraint is not satisfied anymore, there is really big difference. Even the minimum of 1/2*x*H*x is totally bad. Is there any other way to do what i need?</p><p>Thanks a lot :)</p>Miroslav Strbahttps://www.mathworks.com/matlabcentral/profile/authors/10166822-miroslav-strbatag:www.mathworks.com,2005:Question/3581112017-09-24T13:06:38Z2017-09-24T13:47:20ZHow to load large number of files and perform looping through each file?<p>I have 153 files stored in a directory with extension of .txt. I want to load each and every file in a script and perform a mathematical calculation using for loop.</p>Chris Martinhttps://www.mathworks.com/matlabcentral/profile/authors/11052987-chris-martintag:www.mathworks.com,2005:Question/3580992017-09-24T10:45:08Z2017-09-24T13:44:52Zhow to use matlab code tp plot following <p>(a) plot s(t) and its magnitude frequency spectrum</p><p>(b) plot the modified signal x(t)=s(t)*cos(2πfct) in both time and frequency spectrum.</p><p>(c) Assuming a perfect coherent demodulation, plot the output (in time and magnitude spectrum) of the demodulator mixer.</p><p>(d) Plot the output (in time and magnitude spectrum) of the ideal low pass filters with bandwidth of 1Hz and 5Hz respectively.</p><p>(e) Repeat parts(c) and (d) assuming a non-ideal mixer with phase error of 5 degree</p><p>(f) Repeat parts(c) and (d) assuming a non-ideal mixer with phase error 0.2Hz</p><img src = "/matlabcentral/answers/uploaded_files/88843/question%20image.JPG">praveen yadavhttps://www.mathworks.com/matlabcentral/profile/authors/11052037-praveen-yadavtag:www.mathworks.com,2005:Question/3580802017-09-24T04:31:08Z2017-09-24T13:40:56Z??? In an assignment A(I) = B, the number of elements in B and I must be the same.<p>Hi, I don't get why my code is incorrect. I hope you guys can help please.</p><pre class="language-matlab">clc;
A=10;
m=1;
k=40;
c=10;
xi=c/(2*sqrt(k*m));
w=1;
wn=sqrt(k/m);
b=(1-(w/wn)^2);
d=(2*xi*w/wn)^2;
Z=A/(b^2+d)^1/2;
fi=atan((2*xi*w/wn)/(1-(w/wn)^2));
muestras=1000;
t0=0;
tf=15;
for i=1:muestras+1
t(i)=t0+(i-1)*(tf-t0)/muestras;
x(i)=Z*sin(w*t-fi);
end
plot(t,x,'g')
xlabel('t')
ylabel('x')
</pre><p>In the command window, it says:</p><pre class="language-matlab">??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
</pre><pre class="language-matlab">Error in ==> AVER at 19
x(i)=Z*sin(w*t-fi);
</pre>Mariela Floreshttps://www.mathworks.com/matlabcentral/profile/authors/9645798-mariela-florestag:www.mathworks.com,2005:Question/3580402017-09-23T14:30:49Z2017-09-24T13:39:37ZCreating a 50x50 3D matrix composed of 2x1 vectors <p>I need to create a 50x50 image with each pixel composed of smaller 2x1 vectors using a 3D matrix. This then needs to be put into a nested for loop in order to have each value altered by a function, The 3D matrix will need to be altered back to 2D though before it can go into the function.</p><p>This is the code I have now but I know I am doing something wrong as I keep getting the error that my dimensions do not agree.</p><pre> y_image=zeros(50,50,14001); %creating empty vector for y image values
X_matrix=rand(50,50,2); %creating 50x50 3D image of X values between 0-1 </pre><pre> for row=1:50
for col=1:50
y_image(row,col,:)=R_final*X_matrix(row,col,:);
Y_squeeze=squeeze(y_image(row,col,:));
end
end</pre>C_J4995https://www.mathworks.com/matlabcentral/profile/authors/10757043-c_j4995tag:www.mathworks.com,2005:Question/3580492017-09-23T17:37:59Z2017-09-24T13:33:18ZHow 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://www.mathworks.com/matlabcentral/profile/authors/10774882-blair-halltag:www.mathworks.com,2005:Question/3581072017-09-24T12:48:04Z2017-09-24T13:31:31ZHow to create table of unkown number of matrices with same size?<p>Hello,</p><p>I would like to create table of unknown number of matrices with same sizes, so I can't do it like this:</p><pre class="language-matlab">table1 = table(zeros([5,5]),zeros([5,5]),zeros([5,5]), 'VariableNames', {'matrix1','matrix2','matrix3'});
</pre><p>But here I am stuck because I am not able to find out how to make this without listing zeros([5,5]) n-times, where I don't know what will n be so i had to code it somehow.</p><p>Btw, I need to have variable names set as in previous example too, but making string array for it is not a problem :)</p><p>Thank you :)</p>Miroslav Strbahttps://www.mathworks.com/matlabcentral/profile/authors/10166822-miroslav-strbatag:www.mathworks.com,2005:Question/3581092017-09-24T13:01:22Z2017-09-24T13:30:29ZProblem in using syms operator<p>I wanted to minimize a function involving sums of products over a range [0,x(1)] where x(1) is my variable, when i write my objective function using syms,iteration starts in genetic algorithm solver but it doesn't provide me any solution. But when i write the same function using 'for loops' then it give me solution very quickly.
Why is this happening that writing same function with syms creating problem but not while using loop?</p>Parikshit Sharmahttps://www.mathworks.com/matlabcentral/profile/authors/10929531-parikshit-sharmatag:www.mathworks.com,2005:Question/3581102017-09-24T13:04:44Z2017-09-24T13:28:19ZHow to plot live data from arduino on current HH:MM x axis<p>I can plot live data however I am now trying to plot on an x axis that reflects the time of day that the data was recorded. I have had an attempt (seen below) can anyone see why it isn't working or know how to achieve my task?</p><pre class="language-matlab">%User Defined Properties
</pre><pre class="language-matlab">a = arduino('Com3') % define the Arduino Communication port
</pre><pre class="language-matlab">plotTitle = 'Solar Data Log'; % plot title
</pre><pre class="language-matlab">xLabel = 'Elapsed Time (s)'; % x-axis label
</pre><pre class="language-matlab">yLabel = 'Power (W)'; % y-axis label
</pre><pre class="language-matlab">yMax = 5.5 %y Maximum Value
</pre><pre class="language-matlab">yMin = 0 %y minimum Value
</pre><pre class="language-matlab">plotGrid = 'on'; % 'off' to turn off grid
</pre><pre class="language-matlab">min = 0; % set y-min
</pre><pre class="language-matlab">max = 5.5; % set y-max
</pre><pre class="language-matlab">delay = 1;
</pre><pre class="language-matlab">%Define Function Variables
</pre><pre class="language-matlab">elapsed_hours = delay*60;
</pre><pre class="language-matlab">elapsed_min = delay;
</pre><pre class="language-matlab">t_1 = [08, 00]; % Start time 08:00
</pre><pre class="language-matlab">t_2 = [t_1(1) + elapsed_hours, t_1(2) + elapsed_min*60]; % End time 10:30
</pre><pre class="language-matlab">HH_1 = t_1(1); % Hour digits of t_1
</pre><pre class="language-matlab">MM_1 = t_1(2); % Minute digits of t_1
</pre><pre class="language-matlab">HH_2 = t_2(1); % Hour digits of t_2
</pre><pre class="language-matlab">MM_2 = t_2(2); % Minute digits of t_2
</pre><pre class="language-matlab">time = HH_1/24+MM_1/1440:1/1440:HH_2/24+MM_2/1440
</pre><pre class="language-matlab">%time = 0;
</pre><pre class="language-matlab">data = 0;
</pre><pre class="language-matlab">count = 0;
</pre><pre class="language-matlab">%Set up Plot
</pre><pre class="language-matlab">plotGraph = plot(time,data,'-r' ) % every AnalogRead needs to be on its own
Plotgraph
</pre><pre class="language-matlab">datetick('x','HH:MM')
</pre><pre class="language-matlab">hold on %hold on makes sure all of the channels are
plotted
</pre><pre class="language-matlab">title(plotTitle,'FontSize',15);
</pre><pre class="language-matlab">xlabel(xLabel,'FontSize',15);
</pre><pre class="language-matlab">ylabel(yLabel,'FontSize',15);
</pre><pre class="language-matlab">axis([yMin yMax min max]);
</pre><pre class="language-matlab">grid(plotGrid);
</pre><pre class="language-matlab">tic
</pre><pre class="language-matlab">while ishandle(plotGraph) %Loop when Plot is Active will run until plot is closed
</pre><pre> Vin = readVoltage(a,'A0');</pre><pre> Vout = readVoltage(a,'A1');</pre><pre> Vin = Vin*5.00501002 *1.789;</pre><pre> Vout;</pre><pre> Power = Vin * Vout;</pre><pre> dat = Power %Data from the arduino</pre><pre> count = count + 1; </pre><pre> time(count) = toc; </pre><pre> data(count) = dat(1); </pre><pre> %This is the magic code </pre><pre> %Using plot will slow down the sampling time.. At times to over 20</pre><pre> %seconds per sample!</pre><pre> set(plotGraph,'XData',time,'YData',data);</pre><pre> axis([0 time(count) min max]);</pre><pre> %Update the graph</pre><pre> pause(delay);</pre><pre> end</pre>Jayden Hasemannhttps://www.mathworks.com/matlabcentral/profile/authors/7836657-jayden-hasemanntag:www.mathworks.com,2005:Question/3581082017-09-24T12:59:29Z2017-09-24T12:59:29ZHow do I extract the parameters for all the 'Preset models' of the 'Synchronous Machine' block?<p>I am seeking a systemic way to extract the parameters, instead of going through a crude process of copying them one after the other. I would also appreciate to know the source of the preset parameters; either referenced or estimated.</p>Kingsley Ibrahimhttps://www.mathworks.com/matlabcentral/profile/authors/10522162-kingsley-ibrahimtag:www.mathworks.com,2005:Question/3581002017-09-24T11:54:46Z2017-09-24T12:48:26ZDraw lines between two given sets of points<p>I have two sets of points in 3D. These look for example like:</p><p>S1 = {(x1,y1,z1),(x2,y2,z2),...,(xn,yn,zn)}</p><p>S2 = {(x1',y1',z1'),(x2',y2',z2'),...,(xn',yn',zn')}</p><p>So both sets have the same number of points and I would like to connect them with lines like:</p><p>(x1,y1,z1) ---- (x1',y1',z1')</p><p>(x2,y2,z2) ---- (x2',y2',z2')</p><p>.</p><p>.</p><p>.</p><p>(xn,yn,zn) ---- (xn',yn',zn')</p><p>What would be the best way to achieve that at once? I could do that with a for-loop which will plot a line between each two points, but I am asking, if there's a way I could organise the data so that all lines can be plotted at the same time?...</p><p>Thanks very much for your help in advance!</p><p>Best Regards,</p><p>Ahmed Hossam</p>Ahmed Hossamhttps://www.mathworks.com/matlabcentral/profile/authors/2625160-ahmed-hossamtag:www.mathworks.com,2005:Question/3581062017-09-24T12:46:57Z2017-09-24T12:46:57ZCan't launch addons browser in linux<p>Hello,</p><p>When I click the "addons browser" or "get addons" to be more specific it does not launch and does not give any errors.</p><p>When I run the troubleshooting command:</p><pre class="language-matlab">>> cd(matlabroot)
>> cd bin/glnxa64
>> !./MATLABWindow -url=http://mathworks.com --disable-gpu
</pre><p>I get:</p><pre class="language-matlab">./MATLABWindow: symbol lookup error: /lib64/libpango-1.0.so.0: undefined symbol: g_log_structured
</pre><p>I'm running Fedora 26 and R2017a student.</p><p>Would it have something to with old glib?</p><pre class="language-matlab">glib version installed:
Installed Packages
glib.x86_64 1:1.2.10-48.fc26 @fedora
</pre><p>And pango installed version is:</p><pre class="language-matlab">Installed Packages
pango.i686 1.40.12-1.fc26 @updates
</pre>Ville Koskiniemihttps://www.mathworks.com/matlabcentral/profile/authors/7422652-ville-koskiniemitag:www.mathworks.com,2005:Question/3580692017-09-23T22:46:18Z2017-09-24T12:43:02ZCreating 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://www.mathworks.com/matlabcentral/profile/authors/1754528-snoopytag:www.mathworks.com,2005:Question/3580972017-09-24T09:40:43Z2017-09-24T12:40:45ZI am trying to plot within a for loop, but it only plots the last value, as it's overwritting previous values<pre class="language-matlab">global k
k=1:3;
zeta(k)=0.05;
fo=4;
tf=10;
t=0:tf/1000:tf;
for k=1:3
wdr=input('Enter the damped frequency (wdr(k)) ');
wn=input('Enter natural frequency (wn(k)) ');
end
if (zeta(k)<0 || zeta(k)>=1)
error('Zeta out of range for this program');
end
for k=1:3
wd=wn*sqrt(1-zeta(k)^2);
Ao=fo/sqrt((wn^2-wdr^2)^2+(2*zeta(k)*wn*wdr)^2);
phi=atan2(2*zeta(k)*wn*wdr,(wn^2-wdr^2));
Z1=-zeta(k)*wn-wdr*tan(phi);
Z2=sqrt((zeta(k)*wn)^2+2*zeta(k)*wn*wdr*tan(phi)+(wdr*tan(phi))^2+wd^2);
Z=(Z1+Z2)/wd;
Anum=Ao*((zeta(k)*wn*Z-wd)*cos(phi)+wdr*Z*sin(phi));
Aden=Z*wd;
A=Anum/Aden;
theta=2*atan(Z);
x(k,:)=A*exp(-zeta(k)*wn*t).*sin(wd*t+theta)+Ao*cos(wdr*t-phi);
end
for k=1:1:3
subplot(3,1,k)
plot(t,x(k,:));
title(['Response for zeta=',num2str(zeta(k)),', wn=',num2str(wn),', and wdr=', num2str(wdr)])
xlabel('Time, seconds')
ylabel('Response x')
grid
end
</pre>ROHIT PATELhttps://www.mathworks.com/matlabcentral/profile/authors/6184168-rohit-pateltag:www.mathworks.com,2005:Question/3571772017-09-18T12:56:38Z2017-09-24T12:31:40ZTroubleshooting Matlab Parallel computing bottlenecks<p>Hello,</p><p>can you please tell me if there is some function in Matlab or anything else, that would help me to find bottlenecks of running my code in parallel? Running my code on 1 core takes 2,5 minutes per loop, but on 2 cores it takes almost 4 minutes and running on 5 cores it is 7 minutes. In last option it makes 5 loops during those 7 minutes (because of 1 loop on each core), but in my opinion it has to be slowed by some bottleneck, because it takes really too much time compared to normal 1 core iteration. It is still faster running like this, but I was expecting it to be much better :D</p><p>Thanks :)</p>Miroslav Strbahttps://www.mathworks.com/matlabcentral/profile/authors/10166822-miroslav-strbatag:www.mathworks.com,2005:Question/3581032017-09-24T12:18:34Z2017-09-24T12:18:34Zmxgetpr different variable same pointer<p>Hello,</p><p>Immediately before the call to a mex function some variables are copied into another variable and both copies are passed to the mex function. However, mxGetPr returns the same address for both copies of the variable. I would have thought that when copied to a new variable the data should have been duplicated at a second address and so mxGetPr would return different pointer. Is this not the case? And if not how can I pass two independent copies of some data to a mex function?</p><p>Thanks,</p><p>Jamie</p>JM18https://www.mathworks.com/matlabcentral/profile/authors/8400770-jm18tag:www.mathworks.com,2005:Question/3578712017-09-22T09:14:06Z2017-09-24T12:13:11ZVectors dada danw dwa<p>dadkmas almmd akldmlamlmsda ada</p>Bobby Punjabihttps://www.mathworks.com/matlabcentral/profile/authors/10800345-bobby-punjabitag:www.mathworks.com,2005:Question/436422012-07-15T03:41:29Z2017-09-24T12:11:12ZFinding distance between point and edge of image mask<p>I'm trying to find how far a certain point is from the edge of an ellipse-like shape. The shape is stored as a standard image mask, and the point is in the interior of the shape. What would be the best way to quickly find the shortest distance between the point and mask edge?</p><p>Note: I'll need to calculate this distance for each point in the mask's interior.</p><p>Thanks.</p>Joehttps://www.mathworks.com/matlabcentral/profile/authors/3571032-joetag:www.mathworks.com,2005:Question/3581012017-09-24T12:10:34Z2017-09-24T12:10:34Zabout 400 kw grid connected pv model <p>I am using the 400 kw grid connected pv model as a source to operate a water station consisting of 8 induction motors. this station operate with 50 hz frequency and 400/11000 transformer voltage. when i change transformer primary voltage from 260 volt to 380 volt the value of output voltage of the dc chopper changes from 500 to about 620 ? why does this value change ? as i know this value depends on;y on the value of the duty cycle of switches so how this value is related to the voltage of the primary side of the transformer ?</p>adham osamahttps://www.mathworks.com/matlabcentral/profile/authors/7446648-adham-osamatag:www.mathworks.com,2005:Question/3580572017-09-23T20:17:05Z2017-09-24T11:42:34ZPlot 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://www.mathworks.com/matlabcentral/profile/authors/9173228-suvrat-ramasubramaniantag:www.mathworks.com,2005:Question/3110032016-11-07T11:56:59Z2017-09-24T11:32:41ZNumerical values of integrals<p>I am dealing with a problem of finding accurate numerical values of integrals. Specifically, the integral is introduced by using the best approximation scheme (Legendre Polynomials) to approximate a vector valued function whose indefinite integral is not easy to be explicitly written down. The code is provided as follows:</p><pre> r1 = 0.7; r2 = 1; r3 = r2 - r1; d = 8;</pre><pre> syms y real </pre><pre> le = [];</pre><pre> for i = 0:d
l = [coeffs(legendreP(i,(2/r1)*y+1)) zeros(1,d-i)];
le = [le; l];
end</pre><pre> leg = [];</pre><pre> for i = 0:d
l = [coeffs(legendreP(i,(2*y + r1 + r2)/r3)) zeros(1,d-i)];
leg = [leg; l];
end</pre><pre> syms x
t = [];</pre><pre> for i = 0 : d
t = [t ; x^i];
end
xp = t;</pre><pre> lp = le*xp; la = leg*xp; </pre><pre> fi1 = [exp(sin(x)); exp(cos(x))]; fi2 = [sin(x^2); cos(x^2)];</pre><pre> ny1 = size(fi1,1); ny2 = size(fi2,1); ny = ny1 + ny2; </pre><pre> ga1 = fi1*lp'; ga2 = fi2*la';</pre><pre> Ga1 = double(int(ga1,x,-r1,0)*diag(2.*(0:d)+1)*(1/r1));</pre><pre> Ga2 = double(int(ga2,x,-r2,-r1)*diag(2.*(0:d)+1)*(1/r3));</pre><pre> ep1 = fi1 - Ga1*lp; ep2 = fi2 - Ga2*la;</pre><pre> E1 = double(int(ep1*ep1',x,-r1,0)); E2 = double(int(ep2*ep2',x,-r2,-r1));</pre><p>The code works fine until d = 8 when an error is returned to state that
DOUBLE cannot convert the input expression into a double array. If the input expression contains a symbolic variable, use VPA.</p><p>I have tried vpa function but the same problem happens still.</p><p>One may suggest to use integral numerical integration instead of int. However, the numerical integration seems produce inaccurate result compared to the symbolic representation. Note that the error matrix E1 and E2 become extremely small when the approximation degree d becomes large.</p><p>To summarize, the problem here is how to extract, or accurately calculate if anyone has suggestions, the numerical values of E1 and E2.</p><p>Thanks a lot!</p>Qian Fenghttps://www.mathworks.com/matlabcentral/profile/authors/5192873-qian-fengtag:www.mathworks.com,2005:Question/3580832017-09-24T05:21:25Z2017-09-24T10:56:10ZWrite a program to change brightness and change the contrast of the color image (keep the average brightness of the image). I don't understand how to keep the average brightness of the image. thank you!!!<p>"Write a program to change brightness and change the contrast of the color image (keep the average brightness of the image)."</p><p>I don't understand how to keep the average brightness of the image. thank you!!!</p>Hoang Nguyenhttps://www.mathworks.com/matlabcentral/profile/authors/9288938-hoang-nguyentag:www.mathworks.com,2005:Question/3006662016-08-24T01:43:40Z2017-09-24T10:49:32ZCan MATLAB be run on or interface with the nvidia Jetson series development boards?<p>I am currently in the engineering program at ISU. Presently I am in a class specifically for programming in MATLAB. I see that you have add on packages for interfacing with arduino and raspberry pi which is great. I am curious if you have any support for running Matlab on the Nvidia Jetson TK1 and TX1 platforms? If running Matlab is not an option is there options available to interface with the development board? I have begun to migrate primarily to these platforms from the raspberry pi and arduino or in some cases using in conjunction with the PI and Arduino. Please advise if this will be a possibility.</p><p>Thanks</p>Michael Whipplehttps://www.mathworks.com/matlabcentral/profile/authors/8520330-michael-whippletag:www.mathworks.com,2005:Question/3580862017-09-24T06:40:55Z2017-09-24T10:43:58Zhow to extract roi automatically<p>how to extract blobs (affected region) in lungs CT scan image without free hand selection using auto selection based on color r something . in that extracted output it needs to display only the blobs in white. background needs to be black</p>sathish kumar rbhttps://www.mathworks.com/matlabcentral/profile/authors/9945249-sathish-kumar-rbtag:www.mathworks.com,2005:Question/3156862016-12-06T16:30:20Z2017-09-24T10:43:28Zcalculate the minimum distances between two sets of 3d points<p>Hi all,</p><p>I have two sets of 3D points with different number of elements; one is a trajectory and the other is the coordinates of incenter points of triangle normals for a box, as shown in the figure.</p><p>What I want to calculate is the points from the trajectory matrix that are the closest to any of the triangle normals.</p><p>Any ideas for this?</p><p>Thank you in advance.</p><img src = "/matlabcentral/answers/uploaded_files/64880/img.jpg">Dimitrios Anagnostakishttps://www.mathworks.com/matlabcentral/profile/authors/8138455-dimitrios-anagnostakistag:www.mathworks.com,2005:Question/3580982017-09-24T09:47:38Z2017-09-24T10:18:39ZHow can I perform arithmetic operations with RGB values?<p>I have an image, and I want to get values of a parameter for each pixel of the image. The parameter is a function of the RGB values of the image. In order to evaluate the parameter, I need to perform basic arithmetic operations involving RGB values, but I am not able to to that as RGB values are scaled ones. e.g., if R=243, and I want to add 30 with it, the answer becomes 255 instead of 273, as that is the maximum permissible limit for the pixel intensity values. What I understand is that I cannot treat RGB values as general numeric entities. Any help regarding converting them into numerical values so that arithmetic operations can be performed is highly appreciated.</p>Sreerup Banerjeehttps://www.mathworks.com/matlabcentral/profile/authors/8540521-sreerup-banerjeetag:www.mathworks.com,2005:Question/3577662017-09-21T15:50:43Z2017-09-24T10:18:21ZHow to plot contour as a function of radius and height?<p>I have written a code for magnetic field on surface as a function of radius and height.. I want graph of variation in magnetic field on the surface as the magnetic lines appear i.e., diverging.. The code is here:
%magnetic field normal to the surface</p><pre class="language-matlab">clc;
clear all;
close all;
</pre><pre class="language-matlab">hob=2.5*10^3;
</pre><pre class="language-matlab">h=200000:100000:5000000;
</pre><pre class="language-matlab">c=3*10^8; %m/s velocity
</pre><pre class="language-matlab">len1=length(h);
</pre><pre class="language-matlab">bsquare=10^10:(10^15-10^10)/(len1-1):10^15; %m2
</pre><pre class="language-matlab">b=bsquare.^0.5;
</pre><pre class="language-matlab">len2=length(b);
</pre><pre class="language-matlab">area=bsquare.*pi;
</pre><pre class="language-matlab">ho=zeros(len1,len2); %mag field
</pre><pre class="language-matlab">fh=zeros(len1,len2); %electron gyro freq
</pre><pre class="language-matlab">wh=zeros(len1,len2); %ang freq
</pre><pre class="language-matlab">m=9.1094*10^-28; %gram electron mass
</pre><pre class="language-matlab">e=1.6*10^-19; %charge
</pre><pre class="language-matlab">for i=1:len1
</pre><pre> for j=1:len2</pre><pre> ho(i)=hob*(1-(h(i)/((h(i)^2)+bsquare(j))^0.5));</pre><pre> wh(i)=e*ho(i)/(m*c);</pre><pre> fh(i)=wh(i)/(2*pi);</pre><pre> end</pre><pre class="language-matlab">end
</pre><pre class="language-matlab">figure;
</pre><pre class="language-matlab">t=[h:b];
</pre><pre class="language-matlab">contour3(b,h,ho,128);%logspace(-2, 3, 20));
</pre><pre class="language-matlab">% plot3(b,h,ho);
</pre><pre class="language-matlab">xlabel('x-radius');ylabel('y-height');zlabel('z-magnetic field');
</pre><pre class="language-matlab">grid on;
</pre><pre class="language-matlab">hold on;
</pre>Saumitra Lalsarehttps://www.mathworks.com/matlabcentral/profile/authors/6998724-saumitra-lalsaretag:www.mathworks.com,2005:Question/3580222017-09-23T10:32:50Z2017-09-24T09:27:31ZHow 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://www.mathworks.com/matlabcentral/profile/authors/2077384-maxroucooltag:www.mathworks.com,2005:Question/3580922017-09-24T08:05:59Z2017-09-24T09:10:48Zi have a matrix with positive values, but when im using imshow im getting white plane.Why is it ?<p>my matrix have values like</p><pre> 801195.672906465,740500.922136101</pre><p>and so on.</p>kitty varghesehttps://www.mathworks.com/matlabcentral/profile/authors/10557526-kitty-varghesetag:www.mathworks.com,2005:Question/3580932017-09-24T08:08:40Z2017-09-24T09:08:42Zwhy matlab 2016a is not opening in windows 7 after installation and activation<p>After installation and activation matlab 2016a is not opening in windows 7. I have tried many times but it did not work. Kindly help.</p>Swetanjali Nayakhttps://www.mathworks.com/matlabcentral/profile/authors/10394790-swetanjali-nayaktag:www.mathworks.com,2005:Question/3573822017-09-19T13:50:40Z2017-09-24T09:08:15Zusing function in matlab<p>hi,i want to write a function who get radius and number of circles that should be in the primary circle.</p><p>this is what i wrote till now,but still it not call to the function unfortunately.</p><pre class="language-matlab">function [ ] = drawcircle( r,n )
hold on;
for i:1:n
theta=linspace(2*pi/n,2*pi,n);
x=r*cos(theta);
y=r*sin(theta);
plot(y,x)
hold off;
</pre><p>main -</p><pre class="language-matlab">count=3;
r=5;
theta=linspace(0,2*pi);
drawcircle(r,count);
plot(y,x)
</pre>yuval ohayonhttps://www.mathworks.com/matlabcentral/profile/authors/10651585-yuval-ohayontag:www.mathworks.com,2005:Question/3580942017-09-24T08:26:12Z2017-09-24T09:04:23ZHow to fix the Error During Packaging issue in MATLAB stand-alone application building?<img src = "/matlabcentral/answers/uploaded_files/88838/BUG.JPG"><p>I'm facing a problem to building the exe file using MATLAB compiler. Please see the attached stuff and help me to fix the bug!</p>FARHADhttps://www.mathworks.com/matlabcentral/profile/authors/5028290-farhadtag:www.mathworks.com,2005:Question/3580962017-09-24T08:44:24Z2017-09-24T08:54:50ZHow can I increase my vector by increments of 100 but end on 558?<p>I need to create a vector that starts at 0, increases by 100 each time but ends at 558.</p><p>The following outlines my function:</p><p>x_int = 0:100:558</p><p>This works except it only calculates up to 500 and not 558.</p>Clare Fergusonhttps://www.mathworks.com/matlabcentral/profile/authors/6480001-clare-fergusontag:www.mathworks.com,2005:Question/3580952017-09-24T08:31:07Z2017-09-24T08:31:35ZHi,How to generate Pulses using Sinusoidal PWM technique with four reference signal and one carrier? pls help me<p>VrefUA = mU sinωt + offsetU
VrefUB = mU sin(ωt +ϕ1) + offsetU
VrefLA = mL sinωt + offsetL
VrefLB = mL sin (ωt +ϕ2 ) + offsetL</p>dhivya khttps://www.mathworks.com/matlabcentral/profile/authors/6292137-dhivya-ktag:www.mathworks.com,2005:Question/3580522017-09-23T19:05:53Z2017-09-24T08:24:05ZIs 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://www.mathworks.com/matlabcentral/profile/authors/11047956-nicholas-haastag:www.mathworks.com,2005:Question/3548572017-09-01T12:42:34Z2017-09-24T08:23:48ZUsing aoctool for a 1-way ANCOVA (+plot)<p>I have two groups of subjects, each with scores on a memory task and on an IQ test. I would like to check whether there's a significant group difference in the memory measure while controlling for IQ.</p><p>I reckoned that for that, I need a 1-way between-subjects ANCOVA, with DV=memory score, predictor=group, and covariate=IQ. The Matlab command to achieve this appears to be aoctool.</p><p>Following the example in its (rather incomplete) <a href = "https://www.mathworks.com/help/stats/aoctool.html">documentation</a> , and having coded group as a categorical variable, I typed:</p><pre class="language-matlab">[h,a,c,s] = aoctool(PIQ, mem, group, 0.05, 'PIQ','mem','group','off','separate lines');
</pre><p>However, that just gives me the slopes&intercepts for the groups, which does not help me. What I need is a categorical comparison between the groups, rather than a regression between x vs y, as the aoctool example seems to put it.</p><p>How can I use aoctool to:</p><ol><li>obtain a p-value for the between-subjects effect of the group factor?</li><li>scatter-plot the memory score as a function of IQ, with groups color-coded as in the documentation example? The above command does return a figure handle h, but it's an empty matrix (even in the case of the example dataset!), and I don't think it can be used to base a plot on it.</li></ol><p>Thanks for any help!</p>z8080https://www.mathworks.com/matlabcentral/profile/authors/8237042-z8080tag:www.mathworks.com,2005:Question/3045282016-09-26T09:47:48Z2017-09-24T08:04:13ZTUTORIAL: Why Variables Should Not Be Named Dynamically (eval)<p>Beginners sometimes want to dynamically create or access variable names, the variables are often named something like these:</p><ul><li><tt>data1</tt>, <tt>data2</tt>, <tt>data3</tt>, <tt>data4</tt>, ...</li><li><tt>test_20kmh</tt>, <tt>test_50kmh</tt>, <tt>test_80kmh</tt>, ...</li><li><tt>userinput1</tt>, <tt>userinput2</tt>, <tt>userinput3</tt>, ...</li></ul><p>There are many reasons why using dynamic variable names is a really <b>bad way to write code</b>, in particular (click the links to jump to the "answers" below):</p><ul><li><a href = "http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval#answer_236117"><b>Slow</b></a></li><li><a href = "http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval#answer_236118"><b>Buggy</b></a></li><li><a href = "http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval#answer_236119"><b>Security Risk</b></a></li><li><a href = "http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval#answer_236120"><b>Difficult to Work with</b></a></li><li><a href = "http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval#answer_236121"><b>Obfuscated Code Intent</b></a></li><li><a href = "http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval#answer_236122"><b>Confuses Data with Code</b></a></li><li><a href = "http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval#answer_236123"><b>Code Helper Tools do not Work</b></a></li><li><a href = "https://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval#answer_274740"><b>Magically Making Variables Appear in a Workspace is Risky</b></a></li></ul><p>There are much <b>better alternatives</b> to accessing dynamic variable names:</p><ul><li><a href = "http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval#answer_236124"><b>Indexing into Cell Array or ND-Array</b></a></li><li><a href = "http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval#answer_236126"><b>Non-scalar Structures (with Indexing)</b></a></li><li><a href = "http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval#answer_236125"><b>Dynamic Field-Names in a Structure</b></a></li><li><a href = "http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval#answer_236127"><b><tt>load</tt> into a Structure, not into the Workspace</b></a></li><li><a href = "http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval#answer_236128"><b>Use more Efficient Ways to Pass Variables between Workspaces</b></a></li></ul><p>Usually some <a href = "http://www.mathworks.com/help/matlab/indexing.html">simple and efficient indexing</a> is the key! It is important to realize that putting sequential numbers into variable names is <i>de-facto</i> indexing, which would be simpler and more efficient if it were turned into <i>real</i> indexing.</p><p>If you are not interested in reading the answers below then at least read MATLAB's own documentation on this topic: <a href = "http://www.mathworks.com/help/matlab/matlab_prog/string-evaluation.html"><b>Alternatives to the <tt>eval</tt> Function</b></a>. Note that all of these problems and disadvantages also apply to functions <a href = "https://www.mathworks.com/help/matlab/ref/assignin.html"><tt>assignin</tt></a>, <a href = "https://www.mathworks.com/help/matlab/ref/evalin.html"><tt>evalin</tt></a>, and <a href = "https://www.mathworks.com/help/matlab/ref/evalc.html"><tt>evalc</tt></a>, and the <a href = "https://www.mathworks.com/help/matlab/matlab_prog/techniques-for-improving-performance.html?s_tid=gn_loc_drop">MATLAB documentation</a> explicitly recommends to <i>"Avoid functions such as <tt>eval</tt>, <tt>evalc</tt>, <tt>evalin</tt>, and <tt>feval(fname)</tt>"</i>.</p><p>The MATLAB blogs also explain <a href = "http://blogs.mathworks.com/loren/2005/12/28/evading-eval/">why <tt>eval</tt> should be avoided</a>, the better <a href = "http://blogs.mathworks.com/loren/2006/01/04/more-in-eval/">alternative to <tt>eval</tt></a>, and <a href = "http://www.mathworks.com/matlabcentral/answers/51946-systematic-do-not-use-global-don-t-use-eval">experienced MATLAB users also clearly recommend avoiding using <tt>eval</tt> for trivial code</a>. Using <tt>eval</tt> comes out at position <i>number one</i> on this list of bad code practices: <a href = "http://blogs.mathworks.com/videos/2010/03/08/top-10-matlab-code-practices-that-make-me-cry/">Top 10 MATLAB Code Practices That Make Me Cry</a>.</p><p>Note that avoiding <tt>eval</tt> (and <tt>assignin</tt>, etc.) is not some esoteric MATLAB restriction, it also applies to many other programming languages as well:</p><ul><li><a href = "http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval#answer_236129"><b>Other Languages: do not use <tt>eval</tt>!</b></a></li></ul>Stephen Cobeldickhttps://www.mathworks.com/matlabcentral/profile/authors/3102170-stephen-cobeldicktag:www.mathworks.com,2005:Question/3570462017-09-17T10:37:43Z2017-09-24T08:03:33Z[Zynq ad9361 fmscomms2] Frame Size increase<p>Hello,</p><p>I'm working in a project related to design a SDR communication system
to streaming video used on QPSK modulation.</p><p>Hardware is ad9361 fmscomms2 with zedboard</p><p>We based on this example : <a href = "https://www.mathworks.com/help/supportpkg/xilinxzynqbasedradio/ug/zedboardandfmcomms234transmitter.html">https://www.mathworks.com/help/supportpkg/xilinxzynqbasedradio/ug/zedboardandfmcomms234transmitter.html</a></p><p>And i have some question about the interface model example</p><p>zynqRadioHWSWQPSKAD9361AD9364SL_interface.</p><ul><li>In the data generation part as i understand in the "for iteration
subsystem" we packing 200xdouble same message data (154 data + 26
barker code + 20 bernoulli i will call it a packet)x50 times to
construct 10000xdouble data frame length.</li></ul><p>Can I change it to packing only one packet without iterator the same
packet data.</p><p>Because I planning to support ethernet frame with MTU is 1500. The
message data now is 22 bytes (*Zynq HW/SW Co-design*) and I want to
increase it.</p><ul><li>Another problem is when data is transfer from ARM to PL and PL to
ARM through DMA we alway get a error in first bytes. When I select src
select from ARM. And I don't know why.</li></ul><p>Many thanks.</p>hoang viethttps://www.mathworks.com/matlabcentral/profile/authors/7031254-hoang-viettag:www.mathworks.com,2005:Question/3142832016-11-28T05:49:22Z2017-09-24T07:58:03ZHow can I use TensorFlow library from matlab environment?<p>I want to use or access TensorFlow library from Matlab environment, especially for machine learning. How can I use TensorFlow library from matlab ?</p>K M Ibrahim Khalilullahhttps://www.mathworks.com/matlabcentral/profile/authors/7463294-k-m-ibrahim-khalilullahtag:www.mathworks.com,2005:Question/3579852017-09-22T21:42:12Z2017-09-24T07:45:04ZHow 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://www.mathworks.com/matlabcentral/profile/authors/11034460-rafa-juareztag:www.mathworks.com,2005:Question/3531912017-08-18T09:42:37Z2017-09-24T07:32:11ZHow to use the powergui block for fft analysis using .mat file?<p>I want to use the powergui block for fft analysis.I have set the signals as structures with time in the properties of the scopes and checked the box to saved them into workspace . After running the simulation , I am importing the data from .mat file by using Import Data in the file menu of fft analysis box but the powergui's fft analysis simply does not display anything
Can anyone please suggest a solution to this problem, urgently.</p>Waqas Alihttps://www.mathworks.com/matlabcentral/profile/authors/7368909-waqas-ali