https://nl.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2017-04-27T22:28:27Ztag:nl.mathworks.com,2005:Question/3377142017-04-27T21:24:20Z2017-04-27T22:28:27Zmessy table in one column<p>Hi,
I have a data with some strings and mostly numeric data. The strings are located in the first 11 lanes and then the numeric data is as follows ( that is the pattern until the end of the file). I just would like to get the numeric data but since the number of columns change in each line I have difficulties doing this. I tried many things (textscan, fopen, importdata etc) and I ended up using table with text option.</p><pre class="language-matlab">T1=readtable(fileName, 'FileType', 'text');
T2=T2(11:end,1);
</pre><p>However whatever I do I bumped into another problem and I ended up to have only one column. I can not the access the individual data since it is in the string format. I can not generate variable names neither since it is only one column. Any advice or solution is appreciated.</p><p>================== here is the one column data I ended, and I would like to save this part into another table ========</p><pre class="language-matlab">'1171 4000 24'
</pre><pre class="language-matlab">'4000 7 6000 2 1 12 2 2'
</pre><pre class="language-matlab">'-0.40695E+01 -0.27921E+01 -0.10915E+02 -0.49148E+00 -0.30083E-01 0.87037E+00 0.18997E+00 0.10000E+01 0.22955E+02'
</pre><pre class="language-matlab">'4000 7 1001 2 1 12 2 3'
</pre><pre class="language-matlab">'-0.49538E+01 -0.28463E+01 -0.93488E+01 0.12346E+00 -0.52177E+00 0.84411E+00 0.90250E-01 0.10000E+01 0.23253E+02'
</pre><p>Birsen</p>Birsenhttps://nl.mathworks.com/matlabcentral/profile/authors/2823509-birsentag:nl.mathworks.com,2005:Question/3377202017-04-27T22:26:00Z2017-04-27T22:26:00ZIf I am trying to write a "while" loop for while the bottom row of a matrix has only one non-zero value, what would I write after the "while" to specify only that condition?<p>Lets say I have a matrix of:</p><p>zeros(6,7)</p><p>And I want to run a function only as long as there is one non-zero element in the 6th row. How would I do that until a second non-zero element is placed there?</p>Nathan Sunnarborghttps://nl.mathworks.com/matlabcentral/profile/authors/9608301-nathan-sunnarborgtag:nl.mathworks.com,2005:Question/3377192017-04-27T22:09:52Z2017-04-27T22:11:17ZUndefined Variable or Function Fix?<p>So I have a very long code that is supposed to pull data from a .txt file and use it to run the code. When I directly import a specific .txt file, the code runs properly. However, I want to put the code into a function where I can input any .txt file name and it will run based on that file. Whenever I put it in a function, I get the error "Undefined Variable 'name of file' or function 'name of file'. I'll post the code below (it's very long but I believe the mistake is in the top several lines) if that helps, but I can't figure out why it will work in a script but not a function.</p><pre> function [ V_in, V, V_out ] = PIPE_FLOW( fname_in, units )</pre><pre> if units == 'M'
gamma = 9810;
g = 9.81;
rho = 1000;
nu = 1.12e-6;
elseif units == 'E'
gamma = 62.4;
g = 32.2;
rho = 1.94;
nu = 1.21e-5;
end</pre><pre> format shorteng;
format compact;</pre><pre> A = importdata(fname_in,'%f%f%f%f%f', ' ',1);</pre><pre> n=length(A); </pre><pre> %Preallocate the variable vectors:
P_in = zeros(1,n);
z_in = zeros(1,n);
D_in = zeros(1,n);
P_out = zeros(1,n);
z_out = zeros(1,n);
D_out = zeros(1,n);
K_L = zeros(1,n);
V = zeros(1,n);
L = zeros(1,n);
D = zeros(1,n);
z = zeros(1,n);
rough = zeros(1,n);
H_s_Turb = zeros(1,n);
H_s_Pump = zeros(1,n);
Element_Num_Pipe = zeros(1,n);
Element_Num_Fitting = zeros(1,n);
Element_Num_Turbine = zeros(1,n);
Element_Num_Pump = zeros(1,n);
inlet_i = 0;
fitting_i = 0;
turbine_i = 0;
pipe_i = 0;
pump_i = 0;</pre><pre> for i = 1:2:n-1
line_desc = A{i};
line_data = str2num(A{i+1});</pre><pre> % For each pair of input lines, put data directly into relevant
% variable vector to store the data</pre><pre> % if line_desc = 'inlet', then store variables P_in, z_in and D_in
% if line_desc = 'pipe', store variables in relevant useful locations for
% later use.</pre><pre> switch line_desc
case 'inlet'
inlet_i = inlet_i + 1;
P_in(inlet_i) = line_data(1);
z_in(inlet_i) = line_data(2);
D_in(inlet_i) = line_data(3);
case 'exit'
P_out(inlet_i) = line_data(1);
z_out(inlet_i) = line_data(2);
D_out(inlet_i) = line_data(3);
case 'fitting'
fitting_i = fitting_i + 1;
K_L(fitting_i) = line_data(1);
V(fitting_i) = line_data(2);
Element_Num_Fitting(fitting_i) = line_data(3);
case 'pipe'
pipe_i = pipe_i + 1;
L(pipe_i) = line_data(1);
D(pipe_i) = line_data(2);
rough(pipe_i) = line_data(3);
z(pipe_i) = line_data(4);
Element_Num_Pipe(pipe_i) = line_data(5);
case 'pump'
pump_i = pump_i + 1;
H_s_Pump(pump_i) = line_data(1);
Element_Num_Pump(pump_i) = line_data(2);
case 'turbine'
turbine_i = turbine_i + 1;
H_s_Turb(turbine_i) = line_data(1);
Element_Num_Turbine(turbine_i) = line_data(2);
end</pre><pre> end</pre><pre> %Remove the excess zeros from the end of each variable vector:
P_in = P_in(1);
z_in = z_in(1);
D_in = D_in(1);
P_out = P_out(1);
z_out = z_out(1);
D_out = D_out(1);
K_L = K_L(1:fitting_i);
V = V(1:fitting_i);
Element_Num_Pipe = Element_Num_Pipe(1:pipe_i);
Element_Num_Pump = Element_Num_Pump(1:pump_i);
Element_Num_Turbine = Element_Num_Turbine(1:turbine_i);
Element_Num_Fitting = Element_Num_Fitting(1:fitting_i);
L = L(1:pipe_i);
D = D(1:pipe_i);
z = z(1:pipe_i);
rough = rough(1:pipe_i);
H_s_Turb = H_s_Turb(1:turbine_i);
H_s_Pump = H_s_Pump(1:pump_i);
H_s = H_s_Turb(1) + H_s_Pump(1);</pre><pre> %Reference Variables:
D_1 = D(1);
g = 9.81;
gamma = 9810;
nu = 1.12e-6;</pre><pre> %Guess f:
f_g_1 = 0.025;</pre><pre> %Energy Equation:
Num = (2*g)*((P_out-P_in)/gamma+z_out-z_in-H_s);
Denom_guess = ((D_1./D_in).^4)-((D_1./D_out).^4)-f_g_1.*(L./D).*(D_1^4./D.^4)-K_L.*(D_1^4./D.^4);
Vref = sqrt((Num./Denom_guess));</pre><pre> V_1_guess = Vref(1);
rough_1 = rough(1);
rel_rough = (rough_1/D_1);</pre><pre> %Find a Reynolds Number based on the guessed f:
Re = ((V_1_guess*D_1)/nu);
%Guess f:
if 0 < Re && Re < 2100;
f_1_actual = 64/Re;
elseif Re > 4000
f_g_2 = 0.025; %New friction factor guess
while Re > 4000;
f_1_actual = ((-2*log10((rel_rough/3.7)+(2.5/(Re*(sqrt(f_g_2))))))^-2);
if abs(f_g_2 - f_1_actual) < 10^-5;
break
end
f_g_2 = f_1_actual;
end
else
warning('Transitional Flow - Friction Factor cannot be found');
end</pre><pre> Denom_Actual = ((D_1./D_in).^4)-((D_1./D_out).^4)-f_g_1.*(L./D).*(D_1^4./D.^4)-K_L.*(D_1^4./D.^4);</pre><pre> V_final = sqrt((Num./Denom_Actual));</pre><pre> %Graphing Total Head:
H_L = (V_final./D).*(K_L);
Head_Total = H_s_Pump + H_s_Turb + H_L;
plot(Head_Total);
title('Graph of Total Head from inlet to exit');</pre><pre> V_in = V_final(1);
b = length(V_final);
V_out = V_final(b);</pre>Neil Solanhttps://nl.mathworks.com/matlabcentral/profile/authors/10211907-neil-solantag:nl.mathworks.com,2005:Question/3377182017-04-27T22:06:06Z2017-04-27T22:06:06Zhow to get confidence interval<p>Hi how can I get Confidence interval for regression parameter in matlab ? Thanks</p>farfarhttps://nl.mathworks.com/matlabcentral/profile/authors/7391310-farfartag:nl.mathworks.com,2005:Question/3377172017-04-27T22:06:02Z2017-04-27T22:06:02ZCan I call MATLAB from Python 3.5?<p>I am trying to install the MatLab engine for Python. I am running Python 3.5 and according to MathWorks website, this version is supported. When attempting to install I get an error telling me that Python 3.5 is not supported. So am confused on whether or not it is supported and I am curious as to whether there is a work around somewhere.</p><p>Thanks</p>Teague Tomeshhttps://nl.mathworks.com/matlabcentral/profile/authors/6956001-teague-tomeshtag:nl.mathworks.com,2005:Question/1785682015-02-15T18:33:22Z2017-04-27T22:01:47ZAccurately printing two vectors with fprintf function<p>I have two vectors (take A and B for example)
A = 1:5
B = 10:10:50</p><p>and I want to use the fprintf function to print them as column vectors side by side. I tried inputting them as
fprintf('%5g %5g\n', A, B)</p><p>However, this returns</p><p>1 2;
3 4;
5 10;
20 30;
40 50;</p><p>ans = 95</p><p>How do I use fprintf to display
1 10;
2 20;
3 30;
4 40;
5 50;</p><p>, and how do I prevent ans = 95 from showing up? thanks!</p>Matt Grahamhttps://nl.mathworks.com/matlabcentral/profile/authors/6157654-matt-grahamtag:nl.mathworks.com,2005:Question/3377162017-04-27T21:48:51Z2017-04-27T21:48:51ZCalculate previous and current values from signal builder<p>Hai guys,</p><p>I need your advice as well as help. I use signal builder as an input the matlab function in simulink, and I used the matlab function to calculate the inverse kinematics of my system. The problem now is, I need to calculate difference of the previous and current values from the inverse kinematics.</p><p>For instance, 3 values are sent from signal builder : 0, 30 and 70. These values will be recalculated in the inverse kinematics and I set them as 'theta'. And the next thing that I want to do is to calculate : 30 - 0 = 30;
70 - 30 = 40;</p><p>But I dont have any idea to do that since the input is in signal builder. Hope any of you could helps or advice me on this matter. Thanks</p><p>-CT_</p>siti khadijahhttps://nl.mathworks.com/matlabcentral/profile/authors/5299676-siti-khadijahtag:nl.mathworks.com,2005:Question/3377152017-04-27T21:25:04Z2017-04-27T21:25:04Zhow to get residual for regression <p>Hello
I have one question about regression residual. when I obtain the regression , I use : err = immse(X,Y) to get the error. but it is usually different from other people's result. for calculating the error of a regression, should we consider MSE or just standard error and is the code the right one to calculate it in Matlab? Thanks</p>farfarhttps://nl.mathworks.com/matlabcentral/profile/authors/7391310-farfartag:nl.mathworks.com,2005:Question/3377132017-04-27T21:09:31Z2017-04-27T21:20:02ZHow to create boundary for cloud of points where data is "convex"?<p>I have a dataset of 5600 points that I would like to create a boundary to the entire cloud when I scatter (x,y). If done with the boundary(x,y,1) function what I get a lasso that is does not pick enough points, especially where my data becomes a little convex. I'm open to other methods because what I really want is a curve that picks my MAX values as it moves in x, kind of a blanket over my data. This becomes difficult when the gradient between points becomes large.</p><p>Additionally, the dataset of course isn't nicely ordered, it's very random.</p>BBhttps://nl.mathworks.com/matlabcentral/profile/authors/10232364-bbtag:nl.mathworks.com,2005:Question/3376982017-04-27T19:02:14Z2017-04-27T21:18:11ZHow can I plot a graph where point colour relies on its value, based on several greater than and less than rules?<p>I am trying to plot graphs where the points against the Y-axis determine the point itself to be one of five or more colours based on rules such as <0, >0 & <5, >5 & <42 etc.</p>Ryan Hicksonhttps://nl.mathworks.com/matlabcentral/profile/authors/10056128-ryan-hicksontag:nl.mathworks.com,2005:Question/3377102017-04-27T20:37:48Z2017-04-27T21:14:28ZCan i multiply a binary one with a decimal number?<p>I was trying to convert a decimal number into binary vector. I was assuming i could use those vectors in the equation next and store the values but it gives me weird answers? How can i tackle this problem?</p><img src = "/matlabcentral/answers/uploaded_files/76367/Pics.PNG">Ashhad KHANhttps://nl.mathworks.com/matlabcentral/profile/authors/7028680-ashhad-khantag:nl.mathworks.com,2005:Question/3375132017-04-26T23:03:12Z2017-04-27T21:12:47ZHow to plot using the mod function?<p>I'm trying to plot an energy graph, and I'm having trouble plotting both the mod function. I don't understand why I cannot plot each point when mod(t,etime) == 0 and mod(t,ptime) == 0. The mod(t,etime) == 0 function only plots at the end, and I would like it to plot continuously. Could someone please help me figure this out?</p><pre> function MDSim(T,sigma,m,dt,rc,L,k,ptime,etime)
tempcontrol=input('Would you like Temperature Control? [Y/N] \n','s');
while (tempcontrol ~= 'n' && tempcontrol ~= 'y')
tempcontrol=input('Would you like Temperature Control? [Y/N] \n', 's');
end</pre><pre> [xpos,ypos,vx,vy]=Initialize(sigma,L,k);</pre><pre> h=cell(8);</pre><pre> for i=1:64
h{i}=rectangle('Position',[xpos(i)-0.5*sigma ypos(i)-0.5*sigma sigma sigma],'Curvature',[1 1], 'FaceColor','b');
axis equal
end</pre><pre> t=0;
while T > t
t=t+1;
[xpos,ypos,vx,vy,U_tot,K_avg_tot,E_tot]=Step(xpos,ypos,vx,vy,dt,m,L,sigma,rc,k,tempcontrol);
if mod(t,ptime) == 0
for j=1:64
figure(1);
set(h{j},'Position',[xpos(j)-0.5*sigma ypos(j)-0.5*sigma sigma sigma])
axis equal
end
hold on
drawnow
hold off
end
if mod(t,etime) == 0</pre><pre> %disp(['Total Energy is: ', num2str(E_tot)])
figure(2);
plot(t,(U_tot),'rd', t,(K_avg_tot),'b+',t,(E_tot),'m*')</pre><pre> title('Total Energy (E), Potential Energy (U),Kinetic Energy (K) vs. Time (s)');
xlabel('Time (ds)');
ylabel('Energy (J)');
legend('E','U', 'K', 'Location', 'EastOutside');</pre><pre> hold on
drawnow()</pre><pre> hold off
end</pre><pre> end
end
% </pre>Akhil Vasvanihttps://nl.mathworks.com/matlabcentral/profile/authors/7894695-akhil-vasvanitag:nl.mathworks.com,2005:Question/3370012017-04-24T14:13:03Z2017-04-27T21:10:47ZHow can I create a geometry in matlab which I can export to FEA software for analysis?<p>I created a 2D model in MATLAB using the coordinate of the boundaries (See the attached picture). Currently, it is saved as figure file in MATLAB. I want to import this model to a meshing software to create mesh and from there to an FEA software (Abaqus) for FEA analysis and import it back to MATLAB for optimization. Please, how can I achieve this? Thank you.</p>SAMUEL AYINDEhttps://nl.mathworks.com/matlabcentral/profile/authors/7005176-samuel-ayindetag:nl.mathworks.com,2005:Question/3377082017-04-27T20:26:24Z2017-04-27T21:10:20ZHow to download a file .m for ga algorithm ? <p>Hello, please how can i download this file @cantileverConstraintsWithDisc from this link <a href = "http://fr.mathworks.com/help/gads/solving-a-mixed-integer-engineering-design-problem-using-the-genetic-algorithm.html">http://fr.mathworks.com/help/gads/solving-a-mixed-integer-engineering-design-problem-using-the-genetic-algorithm.html</a>
i need it to do a simulation of ga. Thank you so much.</p>houda mejrihttps://nl.mathworks.com/matlabcentral/profile/authors/9669688-houda-mejritag:nl.mathworks.com,2005:Question/3367702017-04-23T09:15:15Z2017-04-27T21:09:01ZProbability of obtaining x when giving y<p>I have a data set of Power, depending on wind . The data looks like this:</p><img src = "/matlabcentral/answers/uploaded_files/75897/data.png"><p>I want to calculate the following:</p><p>For a certain velocity ( x axis) = 9
There is a probability of 90% that the values are in between 0.9 & 1 for example.</p><p>The purpose is to make after a forecast where I will have a certain velocity and I have to provide a power.</p><p>Thanks in advance</p>André Bernal Garcíahttps://nl.mathworks.com/matlabcentral/profile/authors/9854639-andre-bernal-garciatag:nl.mathworks.com,2005:Question/3377122017-04-27T21:03:30Z2017-04-27T21:03:30ZHi can some one help me how to solve 9 bus system using MATPOWER.<p>i am estimating 9 bus parameters (phase angles) using Kalman filter but unable to solve 9 bus system using MATPOWER. how to use this MATPOWER???
and also if someone share code of Generalized observer scheme and dedicated observer scheme using Kalman filter.</p>Saad Abbasihttps://nl.mathworks.com/matlabcentral/profile/authors/10232348-saad-abbasitag:nl.mathworks.com,2005:Question/3376892017-04-27T18:10:06Z2017-04-27T21:01:52Zhow to plot Zakharov function? Can anyone help me pls<p>I want to plot a 2D surface plot of zakharov test function</p>humahttps://nl.mathworks.com/matlabcentral/profile/authors/9568107-humatag:nl.mathworks.com,2005:Question/3369862017-04-24T12:33:50Z2017-04-27T21:00:11Zerror with manual audio annotation add-on<p>Hello,</p><p>I used matlab to install this add-on: <a href = "http://www.mathworks.com/matlabcentral/fileexchange/18378-manual-audio-annotation">http://www.mathworks.com/matlabcentral/fileexchange/18378-manual-audio-annotation</a></p><p>When I run it, it fails since its using an older api call (waveread) which has been replaced with the new api call (audioread) which can read multiple types of audio files and not just .wav files.</p><p>So, when I run the add-on it breaks in the matlab.m code for this add-on when it tries to perform waveread(). I modified the code in the add-on to use audioinfo and audioread, however when I now run the code it says it can not find audioinfo.m in path. Also, at the command line in the debugger when it fails, I can not type the audioinfo() routine either. It also has the same error message.</p><p>So, do add-ons have a seperate path from the normal matlab installation? How do I solve this problem? I am using the 2017 version of matlab on osx.</p><p>JOhn</p>John Davishttps://nl.mathworks.com/matlabcentral/profile/authors/6032777-john-davistag:nl.mathworks.com,2005:Question/3377072017-04-27T20:06:41Z2017-04-27T20:52:10ZThe following figure shows the cross roads between several streets. The traffics on some of the streets (the ones with a number next to them) are measured by installing sensors. Use Matlab to find the traffic on all the streets.<p>help me with this</p>JEET MASTERhttps://nl.mathworks.com/matlabcentral/profile/authors/10161982-jeet-mastertag:nl.mathworks.com,2005:Question/3370132017-04-24T15:10:50Z2017-04-27T20:46:37ZHow to generate lower triangle in a matrix where elements are the inverse of the upper traingle and diagonal is one<p>I want to generate a matrix where lower triangle elements are the inverse of upper triangle elements and diagonal elements are one.</p><p>where user inputs the upper triangle elements and lower triangle elements are generated automatically. I have attached the required matrix as an example. Thanks!</p>Sanjeev Goyalhttps://nl.mathworks.com/matlabcentral/profile/authors/9702442-sanjeev-goyaltag:nl.mathworks.com,2005:Question/3377112017-04-27T20:38:25Z2017-04-27T20:39:41ZMean of varying range in a 604803x3 array<p>Hi, I am trying to classify an EEG signal from Graz data set b, which consists of a 604803x3 array to define the data. Every row represents EEG signal along time, while every column represents a channel (three relevant channel in total). I've extracted the various features I need for classification, however, I am having trouble reorganizing the data.</p><p>One of the features I have extracted is the Bandpower Estimate for two frequency ranges, which gives me two 604803x3 matrices of the bandpower at each time point for all three channels. I have another column vector called HDR.TRIG that contains the relevant time points I needs (120 in total). What I want to do is calculate the mean of bandpower at each HDR.TRIG for a range defined by sampling rate*time, per channel, to produce a 120x3 matrix.</p><p>I've done the following to produce a 120x3 matrix, but I am absolutely positive that this is wrong since there is no separability for classification, when there should be.</p><pre class="language-matlab">%% Data Restructuring
StRate = HDR.SampleRate*0.5;
EnRate = HDR.SampleRate*2.5;
</pre><pre class="language-matlab">for i = 1:length(HDR.TRIG)
T = HDR.TRIG(i,1);
</pre><pre> % BPE for 10-12 Hz for each channel
for ch = 1:3
BPE1(i,ch) = mean(BPEsensor((T+StRate):(T+EnRate),ch));
end</pre><pre> % BPE for 16-24 Hz for each channel
for ch = 4:6
BPE2(i,ch-3) = mean(BPEsensor((T+StRate):(T+EnRate),ch));
end
end</pre><p>The parameters are as such:</p><ol><li>BPEsensor --> 604803x6 matrix containing BPE1 in columns 1:3 and BPE2 in columns 4:6</li><li>BPE1 --> Contains bandpower from a certain frequency range</li><li>BPE2 --> Contains bandpower from another range.</li></ol><p>Essentially, I want BPE1 and BPE2 to be 120x3 matrices each containing data for each bandpower. I've been attempting this problem for a very long time and am on the verge of giving up. Any guidance to point me in the right direction would be very much appreciated.</p>Siddhartha Dhimanhttps://nl.mathworks.com/matlabcentral/profile/authors/8088805-siddhartha-dhimantag:nl.mathworks.com,2005:Question/3376972017-04-27T19:01:29Z2017-04-27T20:39:03ZWhat is the best way to vectorize this matrix problem?<p>I have a square matrix A which I would like to manipulate using a "map" matrix D. The result will be the matrix B. The entry B(i, j) will be a sum of a number of elements from A(:, j), as determined by D. In the following example, the matrix D tells me that A(1, 1) will be added with A(3, 1) to form B(1, 1), and so on. When the matrices are large, this process takes a long time. Is there a way to vectorize this computation?</p><pre class="language-matlab">A = magic(3); % initial matrix
D = [1, 2, 3; 2, 2, 3; 1, 3, 1]; % map matrix
B = zeros(3); % resultant matrix
for i = 1:3
for j = 1:3
B(D(i, j), j) = B(D(i, j), j) + A(i, j);
end
end
</pre>John Malikhttps://nl.mathworks.com/matlabcentral/profile/authors/9179749-john-maliktag:nl.mathworks.com,2005:Question/3358612017-04-18T05:54:14Z2017-04-27T20:32:46ZCode Generation for Model Reference containing noninlined S-Function<p>I have a Simulink model that contains a hand written level 2 C S-Function (for which I have an associated mex file).</p><p>This model is included as a model reference in a top level model.</p><p>I can generate code at the sub model level containing the S-Function.</p><p>When I attempt to generate code at the top model level, I receive an error as below where it attempts to load an empty string as a file, but I cannot see where this empty string is coming from or if I can set it somewhere.</p><p>Is it possible to generate code at the top level without inlining the s-function?</p><p>Note that the simulation executes from the top level correctly, I just cannot build.</p><pre class="language-matlab">Error using loadTMF
File I/O error on file ''
Operation that caused an error: open
</pre><pre class="language-matlab">The error that occurred was:
Cannot open file. Existence? Permissions? Memory? . . .
</pre><pre class="language-matlab">Error in rtwprivate (line 16)
[varargout{1:nargout}] = feval(function_name, varargin{1:end});
</pre><pre class="language-matlab">Error in coder.internal.processSFunctions
</pre><pre class="language-matlab">Error in coder.internal.processSFunctions
</pre><pre class="language-matlab">Error in coder.internal.processSFunctions
</pre><pre class="language-matlab">Error in coder.internal.ModelBuilder/locNewCodePostCodeGen (line 1616)
coder.internal.processSFunctions( h.ModelName, ...
</pre><pre class="language-matlab">Error in coder.internal.ModelBuilder/buildProcedure (line 694)
[lCodeGenerationId, rpt_generated_flag] = obj.locNewCodePostCodeGen...
</pre><pre class="language-matlab">Error in coder.internal.ModelBuilder/make_rtw (line 176)
buildResult = buildProcedure(obj, h, modelName, cs, isSimBuild, lReportInfo);
</pre><pre class="language-matlab">Error in coder.internal.ModelCodegenMgr/make_rtw (line 8)
buildResult = obj.make_rtw(varargin);
</pre><pre class="language-matlab">Error in make_rtw (line 18)
buildResult = h.make_rtw(varargin{:});
</pre><pre class="language-matlab">Error in build_target
</pre><pre class="language-matlab">Error in build_target
</pre><pre class="language-matlab">Error in build_model_reference_target
</pre><pre class="language-matlab">Error in update_model_reference_targets
</pre><pre class="language-matlab">Error in update_model_reference_targets
</pre><pre class="language-matlab">Error in update_model_reference_targets
</pre><pre class="language-matlab">Error in update_model_reference_targets
</pre><pre class="language-matlab">Error in update_model_reference_targets
</pre><pre class="language-matlab">Error in build_standalone_rtw_target
</pre><pre class="language-matlab">Error in slbuild_private
</pre><pre class="language-matlab">Error in slbuild_private
</pre><pre class="language-matlab">Error in sl (line 15)
[varargout{1:nargout}]=feval(varargin{:});
</pre><pre class="language-matlab">Error in slbuild (line 61)
sl('slbuild_private', mdl, varargin{:});
</pre><pre class="language-matlab">Error in build (line 26)
slbuild('Tata_LPO_1512TC', 'StandaloneRTWTarget','ForceTopModelBuild',true);
</pre>Chris Dyerhttps://nl.mathworks.com/matlabcentral/profile/authors/4973953-chris-dyertag:nl.mathworks.com,2005:Question/3368642017-04-23T22:18:33Z2017-04-27T20:32:03Zhow to to make a car park shows different colors for each dots using matlab?<p>I convert my car park image to binary image and clear the unwanted white dots/region to get this image:</p><img src = "/matlabcentral/answers/uploaded_files/75942/erodebwimage.jpg"><p>This is my original image with 10 green dots:</p><img src = "/matlabcentral/answers/uploaded_files/75943/nocars10green.jpg"><p>This is my codes:</p><pre> sceneImage = imread('nocars10green.jpg');
figure;
imshow(sceneImage);
hsvscene = rgb2hsv (sceneImage);
figure;
imshow (hsvscene);
grayscene = rgb2gray (hsvscene);
figure;
imshow (grayscene);
bwScene = im2bw (grayscene);
figure;
imshow (bwScene);
str = strel('disk',4)
bw = imerode(bwScene,str)
figure;
imshow (bw);</pre><p>How do I convert the binary image after erode so that I can show different colors for different dots?</p><p>I read in this journal.</p><p>Al-Kharusi, Hilal, and Ibrahim Al-Bahadly. "Intelligent parking management system based on image processing." World Journal of Engineering and Technology 2014 (2014).</p><p>it is mentioned:</p><p>if `(newmatrix(y,x) > 0)` % an object is there, if `(e(newmatrix(y,x)) = 0)` this object has not been seen
`(newmatrix(y,x)) = x;` make the value and index 3 equal to the current `X` coordinate.</p><p>and this is their output image:</p><img src = "/matlabcentral/answers/uploaded_files/75944/newmatrixCarPark.JPG"><p>which they convert from this image:</p><img src = "/matlabcentral/answers/uploaded_files/75945/erodeCarpark.JPG"><p>But I don't understand how it works. Can anyone explain to me how it work and how to write the commands to convert my binary image to get the same as their output image in order to get different colors of each dots?</p><p>or if there is any other way to convert it?</p>Scarletz06https://nl.mathworks.com/matlabcentral/profile/authors/9110991-scarletz06tag:nl.mathworks.com,2005:Question/3377092017-04-27T20:29:52Z2017-04-27T20:30:53ZERROR: Create a Python Application with MATLAB Code<p>I need help in this tutorial, when I run my python code, this error shows and not compile:</p><p>Traceback (most recent call last):
File "getmagic.py", line 2, in <a href = "module">module</a>
myMagic = makesqr.initialize()
NameError: name 'makesqr' is not defined</p>Flavio Antonio Rodrigues Juniorhttps://nl.mathworks.com/matlabcentral/profile/authors/8527027-flavio-antonio-rodrigues-juniortag:nl.mathworks.com,2005:Question/3369642017-04-24T10:39:50Z2017-04-27T20:25:19ZMatlab 2d plotting for better clarity<p>Hi, What is the file best format to save the matlab figures to paste in MS word? Actually i am writing my research article in MS word. Please share your ideas.</p>PRABHU SRINIVASANhttps://nl.mathworks.com/matlabcentral/profile/authors/7713332-prabhu-srinivasantag:nl.mathworks.com,2005:Question/3369002017-04-24T04:49:35Z2017-04-27T20:20:47ZHigher derivatives in "PDEPE"<p>When I want to consider "PDEPE" command for 1D PDE like Du/Dt = \nabla^4 u = \nabla \cdot \nabla^3 u,
how can express the higher derivatives in f?</p><p>That is, f = \nabla^3 u. How can I modify this term with DuDx?</p><p>Thanks in advance.</p>Jaesung Leehttps://nl.mathworks.com/matlabcentral/profile/authors/2426370-jaesung-leetag:nl.mathworks.com,2005:Question/3375032017-04-26T21:47:55Z2017-04-27T20:18:48ZButtonDownFcn on Axes after imshow<p>My ButtonDownFcn for my axes does not work after I call imshow</p><pre class="language-matlab">ax = axes;
set('ButtonDownFcn', @(h,e) disp('Hello'));
imshow(img, 'Parent', ax);
</pre><p>Of course I've read the myriad other post with the same problem and the solution seems to be something like this:</p><pre class="language-matlab">ax = axes;
set('ButtonDownFcn', @(h,e) disp('Hello'));
hold on
h = imshow(img, 'Parent', ax);
set(h, 'HitTest', 'off');
</pre><p>When I do this, it does indeed turn off the hittest for the image, but unfortunately when I click the image I am hitting the figure, not the axes. This is confirmed by the following:</p><pre class="language-matlab">>> hittest()
</pre><pre class="language-matlab">ans =
</pre><pre class="language-matlab">Figure (1) with properties:
</pre><pre> Number: 1
Name: ''
Color: [0.9400 0.9400 0.9400]
Position: [1232 1208 570 450]
Units: 'pixels'hittest()</pre><p><b>So how do I force my click to hit the axes and not the figure?</b> My only work around is to set the ButtonDownFcn for the image itself, but this is really not desirable because after some user input I need to overlay (with transparency) a new image which then becomes the top image. I could then set an identical ButtonDownFcn on this new image, but I'm hoping for a better solution than this work around.</p>Michael Vaianahttps://nl.mathworks.com/matlabcentral/profile/authors/7297328-michael-vaianatag:nl.mathworks.com,2005:Question/3376692017-04-27T16:24:13Z2017-04-27T20:17:29Zwhen calling the function NBERbcYY(time(1,20:447),y(20:447,1),UNRATE(20:447,1),LS,LW,LC); and using the "figure" command, no graph displays, only a grayed-out background on the figure window. I don't understand what the problem could be?<p>when calling the function</p><pre class="language-matlab">NBERbcYY(time(1,20:447),y(20:447,1),UNRATE(20:447,1),LS,LW,LC);
</pre><p>and using the "figure" command, no graph displays, only a grayed-out background on the figure window. I don't understand what the problem could be? My professor said that all of the functions were defined correctly and they were all imported correctly, as well. The NBERbcYY function creates recession bars in the graph, the y variable is the Mcoppock curve(a causal fir filter)that was created by my professor.</p><p>Here are the two functions I am using:</p><pre class="language-matlab">function [ah, fh1, fh2] = NBERbcYY(time, y1, y2, LS, LW, LC)
LS = {'-'; '--'; ':'};
LW = [2 1 2];
LC = {'b'; 'm'; 'r'};
</pre><pre class="language-matlab">function y=mcoppock(x)
b=[3 2 2 1 1 1 0 0 0 0 0 0 -3 -2 -2 -1 -1 -1];
a=12;
</pre><pre class="language-matlab">y=filter(b,a,x);
</pre><p>here is the script I used to try and create the graph:</p><pre class="language-matlab">time=[1980+1/12:1/12:2017+3/12];
y=mcoppock(UNRATE);
NBERbcYY(time(1,20:447),y(20:447,1),UNRATE(20:447,1),LS,LW,LC);
</pre><pre class="language-matlab">Cannot find an exact (case-sensitive) match for 'LS'
</pre><pre class="language-matlab">The closest match is: ls in C:\Program Files\MATLAB\R2017a\toolbox\matlab\general\ls.m
</pre><pre class="language-matlab">Did you mean:
</pre><pre class="language-matlab">>> NBERbcYY(time(1,20:447),y(20:447,1),UNRATE(20:447,1)LS,LW,LC);
NBERbcYY(time(1,20:447),y(20:447,1),UNRATE(20:447,1)LS,LW,LC);
↑
Error: Unexpected MATLAB expression.
</pre><pre class="language-matlab">Did you mean:
>> NBERbcYY(time(1,20:447),y(20:447,1),UNRATE(20:447,1)*ls,LW,clc);LS = {'-'; '--'; ':'};
LW = [2 1 2];
LC = {'b'; 'm'; 'r'};
Error using *
Inner matrix dimensions must agree.
</pre><pre class="language-matlab">>> LS = {'-'; '--'; ':'};
LW = [2 1 2];
LC = {'b'; 'm'; 'r'};
>> NBERbcYY(time(1,20:447),y(20:447,1),UNRATE(20:447,1)LS,LW,LC);
NBERbcYY(time(1,20:447),y(20:447,1),UNRATE(20:447,1)LS,LW,LC);
↑
Error: Unexpected MATLAB expression.
</pre><pre class="language-matlab">Did you mean:
>> NBERbcYY(time(1,20:447),y(20:447,1),UNRATE(20:447,1),LS,LW,LC);
>> figure
>> LS = {'-'; '--'; ':'};
LW = [2 1 2];
LC = {'b'; 'm'; 'r'};
>> NBERbcYY(time(1,20:447),y(20:447,1),UNRATE(20:447,1),LS,LW,LC);
>> NBERbcYY(time(1,20:447),y(20:447,1),UNRATE(20:447,1),LS,LW,LC);
>> LS = {'-'; '--'; ':'};
LW = [2 1 2];
LC = {'b'; 'm'; 'r'};
>> figure
Warning: MATLAB has disabled some advanced graphics rendering features by switching to software OpenGL. For more
information, click here.
>> figure,
>> NBERbcYY(time(1,20:447),y(20:447,1),UNRATE(20:447,1),LS,LW,LC);
>> end
end
↑
Error: Illegal use of reserved keyword "end".
</pre><pre class="language-matlab">>> figure, NBERbcYY(time(1,20:447),y(20:447,1),UNRATE(20:447,1)LS,LW,LC);
figure, NBERbcYY(time(1,20:447),y(20:447,1),UNRATE(20:447,1)LS,LW,LC);
↑
Error: Unexpected MATLAB expression.
</pre><pre class="language-matlab">Did you mean:
>> figure, NBERbcYY(time(1,20:447),y(20:447,1),UNRATE(20:447,1)*LS,LW,LC);
Undefined operator '*' for input arguments of type 'cell'.
</pre><pre class="language-matlab">>> figure,NBERbcYY(time(1,20:447),y(20:447,1),UNRATE(20:447,1),LS,LW,LC);
</pre><p>as you can see, I tried several things, even pasting the variable assignment for LS,LW,LC which I shouldn't have to, given that they are already included in the function definition. If anybody has any suggestions that might help me resolve this issue, I would greatly appreciate your input. Thanks in advance.</p>Scott Rachelsonhttps://nl.mathworks.com/matlabcentral/profile/authors/10226732-scott-rachelsontag:nl.mathworks.com,2005:Question/3377022017-04-27T19:29:51Z2017-04-27T20:03:44Zwhat this colon mean in this code<p>buf(:,:) = abs(p(:,1,:));
norm_buf=buf./max(max(buf));</p><p>i have this code as a part of program but i did not get what is mean</p>waad Alzahranihttps://nl.mathworks.com/matlabcentral/profile/authors/6481879-waad-alzahranitag:nl.mathworks.com,2005:Question/3374432017-04-26T15:10:40Z2017-04-27T20:02:03ZHow to model a variable RL branch?<p>Hi,
I would like to implementing a current controlled variable RL branch using integrator. I have one using
i(t) = integ( v(t) - i(t)*R ) / L, but this would develop an algebraic loop, which I want to avoid. Any ideas?</p><img src = "/matlabcentral/answers/uploaded_files/76231/2017-04-26_8-12-56.png">Kun Menghttps://nl.mathworks.com/matlabcentral/profile/authors/9534027-kun-mengtag:nl.mathworks.com,2005:Question/1310742014-05-25T15:59:09Z2017-04-27T20:00:26ZWhy is the c/c++ code generated by MATLAB Coder not standalone, that is, depends on other library?<p>I write a MATLAB function using some functions from Image Processing Toolbox as follow</p><pre> function Y = TestImageAffine(X, T) %#codegen
H = fspecial('gaussian', 7, 0.5);
X = imfilter(X, H, 'cir', 'same', 'conv');
tform = affine2d(T);
outputView = imref2d(size(X));
Y = imwarp(X, tform, 'OutputView', outputView);</pre><p>The 4 c/c++ code files are gernerated successfully by MATLAB Coder as following</p><pre> TestImageAffine.h
TestImageAffine.c
TestImageAffine_types.h
rtwtypes.h</pre><p>In the c/c++ source file "TestImageAffine.c", 4 header files are included as follow</p><pre> #include "libmwimfilter.h"
#include "libmwippfilter.h"
#include "libmwippgeotrans.h"
#include "tmwtypes.h"</pre><p>For the MATLAB function "Y = TestImageAffine(X, T)" above, MATLAB Coder does NOT gernerate the 4 header files above.</p><p>So My question is that why does MATLAB Coder not gernerate the 4 header files above.</p><p>It is well-known that MATLAB Coder can gernerate "STANDALONE" c/c++ code. Why does the C source file above depend on the other header files?</p><p>Afterwards, I find that the 4 head files exist in the installation path "extern" of MATLAB, and the-same-name files are found as following</p><pre class="language-matlab">libmwimfilter.lib
libmwimfilter.dll
libmwippfilter.lib
libmwippfilter.dll
libmwippgeotrans.lib
libmwippgeotrans.dll
</pre><p>So I think that the generated c/c++ code depends on additional library.</p><p>Finally, I add all the header files, library files and dll files into a Microsoft Visual c++ 2010 project, but the build process fails as follow</p><pre class="language-matlab">" unresolved external symbol _ippgeotransCaller referenced in function _ippgeotrans"
</pre><p>I find out the function "ippgeotransCaller" which is declared in the header file "libmwippgeotrans.h", but I do not know the relationship between ippgeotransCaller and _ippgeotransCaller which appears above</p><p>I do not know what's wrong with my work?</p>chen xbhttps://nl.mathworks.com/matlabcentral/profile/authors/4603690-chen-xbtag:nl.mathworks.com,2005:Question/3377052017-04-27T19:43:00Z2017-04-27T19:51:41ZHow to average plots that differ in x and y data?<p>Hello- I currently have three different datasets that signify results of heating up 3 different specimens.
Since they were carried in different times, they vary in time and value, but also differ in the number of datapoints it used.</p><p>I am trying to plot the average of the three.</p><p>Now if the number of datapoints are the same, the method is quite simple- but my case is something like:</p><p>dataset a: 2 x 10 dataset
dataset b: 2 x 15 dataset
dataset c: 2 x 20 dataset</p><p>but imagine they signify a temperature rise. This also starts and ends in different values.</p><p>Doing some research I also found a exchange based program called plotaverage, but it is a bit confusing for me to find out how to use it, and the example I saw of it being used was for datasets that contained the same amounts of data.</p><p>Any help will be greatly appreciated!</p><p>thank you
s</p>Samuelhttps://nl.mathworks.com/matlabcentral/profile/authors/2892071-samueltag:nl.mathworks.com,2005:Question/3376992017-04-27T19:05:40Z2017-04-27T19:50:12Zhow can i get a students license activation key<p>Kindly help me obtain a student license activation key.</p>Dennis Namemahttps://nl.mathworks.com/matlabcentral/profile/authors/10230796-dennis-namematag:nl.mathworks.com,2005:Question/3376192017-04-27T12:05:08Z2017-04-27T19:50:07ZI am unable to display the summation value?<p>while executing the code, I am unable to see the final result.
D-array;</p><p>K- 0 to N=10;</p><pre> syms k;
Summ=symsum(D,k,0,N);</pre>Adhttps://nl.mathworks.com/matlabcentral/profile/authors/9181750-adtag:nl.mathworks.com,2005:Question/3377062017-04-27T19:49:05Z2017-04-27T20:04:04ZCan I match data from several find functions?<p>I am working on a Matlab class project. In this project I made a data file with 20 materials and 5 of their material properties and wanted to allow a user to enter values needed for the 5 properties and have the program tell them what material qualifies. I decided to use 5 find functions to find out which rows (each row is a different material) qualify for each property but I am unsure how to make it find the rows that surpass all the properties since the resulting vectors from the find functions are different sizes.</p><pre class="language-matlab">% Have user enter properties
</pre><pre class="language-matlab">Mod=input('Enter the minimum Young''s Modulus: ');
</pre><pre class="language-matlab">TS=input('Enter the minimum Tensile Strength: ');
</pre><pre class="language-matlab">YS=input('Enter the minimum Yield Strength: ');
</pre><pre class="language-matlab">Den=input('Enter the maximum Density: ');
</pre><pre class="language-matlab">HC=input('Enter the minimum Heat Capacity: ');
</pre><pre class="language-matlab">% Run find statement
</pre><pre class="language-matlab">ModMat=find(Modulus>=Mod);
</pre><pre class="language-matlab">TSMat=find(TensileStrength>=TS);
</pre><pre class="language-matlab">YSMat=find(YieldStrength>=YS);
</pre><pre class="language-matlab">DenMat=find(Density<=Den);
</pre><pre class="language-matlab">HCMat=find(HeatCapacity>=HC);
</pre><pre class="language-matlab">% Show resulting row in material form
</pre><pre class="language-matlab">Material=find(ModMat==TSMat==YSMat==DenMat==HCMat)
</pre>Diana Mikhailhttps://nl.mathworks.com/matlabcentral/profile/authors/9585207-diana-mikhailtag:nl.mathworks.com,2005:Question/3376682017-04-27T16:04:25Z2017-04-27T19:47:04Zwhat is the correct formula of (sum of ...from...to...) in matlab<pre> snrin=(-5:5:55); %initial snr
N=length(ecg); % length of ecg signal
n=(0:N-1);
e=sum (ecg^2) from 0 to N-1; **% I want to write this formula correctly**
f=sum (W^2) from 0 to N-1; *% also this*
A=sqrt(e/(10^(snrin/10))*f); *% also this one*</pre>khiter hindhttps://nl.mathworks.com/matlabcentral/profile/authors/9404109-khiter-hindtag:nl.mathworks.com,2005:Question/3374522017-04-26T15:55:40Z2017-04-27T19:46:18ZIndexing and Iteration issues<p>Input:</p><pre class="language-matlab">for j=1:NS
tsr(j)=((r(j)*rot)/v); %TSR
end
</pre><p>For loop iteration</p><p><b>X(j) requires tsr(j) and a(j).</b></p><p><b>Both X(j) and a(j) changes every loop.</b></p><p>Before, I use X1(i-1), X2 (i-1).</p><p>After receiving suggestions from this forum to use indexing instead, I revised the code using indexing (still a newbie ^^,)</p><p>Any idea on how to approach this? It seems I have to deal with X(j,i-1) where j, indexes to 20 variables (equal to X1,X2, X20) and i has something to do with iteration.</p><p>Kind regards,</p><p>Wes</p>migshttps://nl.mathworks.com/matlabcentral/profile/authors/7189222-migstag:nl.mathworks.com,2005:Question/3377032017-04-27T19:31:42Z2017-04-27T19:39:54Ztoo many output arguments<p>q=1;
Cbi=0;
V=60;
C1=5*10^3;
C2=1*10^6;
E1=1*10^4;
E2=1.5*10^4;
dh=-5000;
p=1;
Cp=1000;
Ca=x(1);
Cb=x(2);
T=x(3);
k1=C1*exp^(-E1/(R*T));
k2=C2*exp^(-E2/(R*T));
f(1)=(q/V)*(Cai-Ca)-k1*Ca+k2*Cb;
f(2)=(q/V)*(Cbi-Cb)+k1*Ca-k2*Cb;
f(3)=(q/V)*(Ti-T)+(dh/(p*Cp))*(k1*Ca-k2*Cb);</p><p>I have Cai and Ti defined in my workspace. When I run fsolve on this function it comes up as too many output arguments. any ideas??</p>Matthew Fernezhttps://nl.mathworks.com/matlabcentral/profile/authors/6911553-matthew-ferneztag:nl.mathworks.com,2005:Question/3377042017-04-27T19:37:19Z2017-04-27T19:37:19ZHow to prevent Matlab Coder from declaring locals as statics?<p>Matlab Coder sometimes marks certain local arrays as static. Although this of course saves time in stack setup, it makes the whole function thread-unsafe. How do we suppress this optimization?</p><p>(I apologize - I lost my example code.)</p>keith russellhttps://nl.mathworks.com/matlabcentral/profile/authors/10216243-keith-russelltag:nl.mathworks.com,2005:Question/3370422017-04-24T17:32:14Z2017-04-27T19:37:17ZHow can I open Hamming Code Model to begin working on simulink?<p>I am unable to open Hamming Code for Simulink in Mac Pro. Is there any way to work on the same. As while using windows computer at the lab, typing in doc_hamming, it opens a window where we can work on it with detail</p>Yasser Salim Khamis Al Aamrihttps://nl.mathworks.com/matlabcentral/profile/authors/9090000-yasser-salim-khamis-al-aamritag:nl.mathworks.com,2005:Question/3375902017-04-27T09:23:45Z2017-04-27T19:36:54ZHow do I debug Matlab NCO HDL Optimized in loop error?<p>I have a simulink file set up as follows:</p><img src = "https://i.stack.imgur.com/nghxQ.png"><p>With a simple state transistion chart:</p><img src = "https://i.stack.imgur.com/1fcZA.png"><p>with the NCO settings as follows:</p><img src = "https://i.stack.imgur.com/OWK6F.png"><p>When I attempt to compile the model, I get the following error:</p><p><i>"Dimensions of the input port 1 are unknown for MATLAB System block "myfile/NCO HDL Optimized1". This can happen when the input port is in a loop, is driven by a Ground block or a source with unspecified dimensions, or if the input port has unconnected signal lines. Consider adding a Signal Specification block with specified dimensions in front of the input port."</i></p><p>I've tried fiddling with the inc port data type converter but have been unable to get rid of the error and searching doesn't seem to bring up much information. However it will work if I remove the state chart.</p><p><b>What debugging steps should I take?</b></p><p><b>Can anyone explain this error?</b></p><p><b>What does the question mark denote on the simulink diagram?</b></p>Lee Thomashttps://nl.mathworks.com/matlabcentral/profile/authors/6419309-lee-thomastag:nl.mathworks.com,2005:Question/3373402017-04-26T06:14:31Z2017-04-27T19:36:45ZHow do I count repeated familiar signals?<p>I am analysing accelerometer data of jumping and there is a specific pattern in the signals. I am quite new to Matlab and I have to identify how many times each jump signal is repeated. How can I identify and count repeated signals?</p><p>One major problem with some methods - there are other signals that have peaks like jumping but a different pattern, so using peaks to identify this is not a great solution.</p>Kurt Vogelhttps://nl.mathworks.com/matlabcentral/profile/authors/8891757-kurt-vogeltag:nl.mathworks.com,2005:Question/3374682017-04-26T17:52:29Z2017-04-27T19:35:07ZHow to get orthogonal eigenvectors for degenerate normal matrix?<p>I know that Matlab can guarantee the eigenvectors of a real symmetric matrix are orthogonal. In fact, for a general normal matrix which has degenerate eigenvalues, we can always find a set of orthogonal eigenvectors as well. But as I tried, Matlab usually just give me eigenvectors and they are not necessarily orthogonal.
Is there any function that can give orthogonal eigenvectors, or is there some fancy alternative way to do it?
Thanks!</p>Zekun Zhuanghttps://nl.mathworks.com/matlabcentral/profile/authors/5550681-zekun-zhuangtag:nl.mathworks.com,2005:Question/3370822017-04-24T20:47:56Z2017-04-27T19:30:15ZNyquist representation of a complex transfer function matrix<p>Hello, i am trying to get this particular representation of a complex transfer function matrix. The problem is, as i am working with a symbolic varible, i do not how to fit the good input argument into the nyquist() function. Here is my program.</p><pre> for i=1:10
gamma(i)=-real(s(i))/wo(i);
end
for l=1:10
D(l,l)=(wo(l)^2-w^2+2*gamma(l)*wo(l)*w);
end
H=subs(Z*inv(D)*conj(Z)');
w=0:1:12;
nyquist(subs(H(1,1)),w);</pre><p>Where wo and gamma are real numbers and Z is a 10x10 matrix with complex numbers. The transfer function is named by H and the symbolic variable is w and from this point i do not know what else to do to get this representation.</p>Javier Mongehttps://nl.mathworks.com/matlabcentral/profile/authors/9733089-javier-mongetag:nl.mathworks.com,2005:Question/3352172017-04-13T12:53:47Z2017-04-27T19:24:10Zpeak width calculation methods<p>Hi</p><p>I'm calculating peak width using half-prominence method . For the peak in the rectangle is there is a method to make the horizontal line the finds the widths to shift up or make vertical line like this image</p><img src = "/matlabcentral/answers/uploaded_files/75047/DeterminePeakWidthsExample_03.png"><p>? . I tried both methods for peak width detection (half-width, half-prominence ) but it gave me the same results .</p><p>Half-prominence</p><pre> close all</pre><pre class="language-matlab">order =9 ;
framelen =15;
</pre><pre class="language-matlab">lx = 20;
% generate sinal
x = 1:1:1432;
y = (AV)';
y = sgolayfilt(y,order,framelen);
% get derivatives
dy = diff(y);
dx = diff(x);
dy_dx = [0 dy./dx];
</pre><pre> findpeaks(y,x,'Annotate','extents','MinPeakProminence',0.006);
% get peaks with width computed by 'findpeaks'
[pks,locs,peakWidth1,p] = findpeaks(y,x,'MinPeakProminence',0.006);</pre><img src = "/matlabcentral/answers/uploaded_files/75045/3.1.jpg"><img src = "/matlabcentral/answers/uploaded_files/75044/3.1.jpg"><p>half-height :</p><pre class="language-matlab">order =7 ;
framelen =11;
x=-AV;
lx = 20;
</pre><pre> sgf = sgolayfilt(x,order,framelen);</pre><pre class="language-matlab">hold on;
sgf= 0.02-sgf;
</pre><pre class="language-matlab">findpeaks(sgf,'MinPeakProminence',0.004,'WidthReference','halfheight','Annotate','extents');
[pks,locs,widths,proms]=findpeaks(sgf,'MinPeakProminence',0.004,'WidthReference','halfheight');
</pre><pre> pks = -pks;
plot(locs,pks,'g*');
text(locs+.02,pks,num2str((1:numel(pks))'));</pre>sarmad mhttps://nl.mathworks.com/matlabcentral/profile/authors/6551379-sarmad-mtag:nl.mathworks.com,2005:Question/3377012017-04-27T19:22:47Z2017-04-27T19:22:47ZWhat is the most recent release of MATLAB someone can get if the license expired Sept 30, 2016?<p>More specifically, can a license that has a Service End Date of Sept 30, 2016, get release R2016a? Thanks!</p>Holly Stewarthttps://nl.mathworks.com/matlabcentral/profile/authors/9340403-holly-stewarttag:nl.mathworks.com,2005:Question/3377002017-04-27T19:18:35Z2017-04-27T19:18:35ZWanting to plot real-time EMG from simulink target scope output (that currently is just used for post-processing) <p>I have a simulink model that will currently output from target scopes after I stop running the collection trial. So, after the trial has ended, the target appears in my MATLAB workspace.</p><p>However, I am interested in displaying the same scope plot in MATLAB in a figure (EMG data, if that helps), in real time. Essentially, I want a plot running in MATLAB as the simulink realtime plot is updating. So, I need to have a continuously updating variable or file, or something, that will allow me to have a variable that is continuously updating that I can manipulate, based upon the target scope data.</p><p>Is this possible? If so, any help is much appreciated!</p>Meghan Kazanskihttps://nl.mathworks.com/matlabcentral/profile/authors/8659374-meghan-kazanskitag:nl.mathworks.com,2005:Question/3376572017-04-27T15:11:31Z2017-04-27T19:17:08ZHow to have a variable in a transfer fucntion ?<p>How do i write this as my transfer function = 1/s^2+Ks+20 when i try i get this</p><p>>> G2 = tf([1],[2 K1 20])
Undefined function or variable 'K1'</p><p>............................</p>Bergsteinn Danielssonhttps://nl.mathworks.com/matlabcentral/profile/authors/6874581-bergsteinn-danielssontag:nl.mathworks.com,2005:Question/3129532016-11-18T22:10:36Z2017-04-27T19:16:24ZDropout Neural Network for Classification<p>Hello,</p><p>I'm studying neural network and i want to know how to do dropout in Matlab for classification. There is something called dropout class, but not much information about that in Matlab. I would like to know if it is possible to apply dropout in neural network in Matlab, and what steps should be done? As far as i know, i have to manipulate the neurons inside hidden layer, however the nntools in Matlab looks like cannot be manipulated. I am trying to create custom neural network, but still i am confused how to create and apply dropout. Unfortunately, i couldn't find any information regarding to this in the internet.</p><p>Thank you</p>nabila ginahttps://nl.mathworks.com/matlabcentral/profile/authors/7682560-nabila-gina