https://au.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2018-06-21T10:23:40Ztag:au.mathworks.com,2005:Question/4067322018-06-21T10:19:44Z2018-06-21T10:23:40ZHow it is possible to change all images orientation to same i.e. to vertical <p>My folder consisting of 1000 binary images with different orientation. I want to make all of them to vertically align. How it will be possible through a single code ? Later I want to save all the vertically aligned images to a new folder.
Note:few images are already in vertical orientation . I want to keep them as it is .</p>Zara Khanhttps://au.mathworks.com/matlabcentral/profile/authors/10893209-zara-khantag:au.mathworks.com,2005:Question/4065282018-06-20T10:33:20Z2018-06-21T10:22:36ZHow can I handle images?<p>I have three images displaying in three axes on a figure. I want to get them handles so I can browse them using a slider.</p><p>How do I give them handles?</p>Stelios Fanourakishttps://au.mathworks.com/matlabcentral/profile/authors/10865530-stelios-fanourakistag:au.mathworks.com,2005:Question/4067312018-06-21T10:15:08Z2018-06-21T10:22:08ZHow can i substitute my for loop with something faster?<p>Hi everybody,
i have a for loop, which is too slow. Can i substitute this for loop with somthing faster?
this is my code:</p><pre> for i = 1:length(peak_indexing)</pre><pre> index = peak_indexing(1,i) - ramp_length;</pre><pre> hwindow = hann(ramp_length+1);</pre><pre> ramp_matrix(i,:) = fft(hwindow.*RadarData(index:peak_indexing(1,i),1)) ;</pre><pre> end</pre><p>thank you!</p>Ashkan Taremi Zadehhttps://au.mathworks.com/matlabcentral/profile/authors/12554252-ashkan-taremi-zadehtag:au.mathworks.com,2005:Question/4064122018-06-19T17:52:28Z2018-06-21T10:20:49ZSolve system of equations that includes derivatives<p>I've got a system of 2nd order differential equations (equations of motion), which are based on a symbolic variable al(t). The target is now to solve this system of equations to get one 2nd order ODE which I can solve later. Using the solve function doesn't work as MATLAB returns a warning that it was unable to find an explicit solution.</p><pre class="language-matlab">gl1=FR==FN*muh
gl2=m*aSx==FR+FB*cos(be)
gl3=m*aSy==FN+FB*sin(be)-FG
gl4=m*(L1^2/3)*dal2-m*(L1/2)*cos(al)*[L2*dbe2*cos(be)-L2*(dbe^2)*sin(be)]...
+m*(L1/2)*sin(al)*[L2*dbe2*sin(be)+L2*(dbe^2)*cos(be)]==FG*(L1/2)*cos(al)-FN*L1*cos(al)+FR*L1*sin(al)
solve(simplify(gl1),simplify(gl2),simplify(gl3),simplify(gl4))
</pre><p>After solving that system I don't want the forces(FB, FR, FN) to appear in the final equation, I just want terms of alpha and its derivatives.</p>Mohammad El-Zoueiryhttps://au.mathworks.com/matlabcentral/profile/authors/9921692-mohammad-el-zoueirytag:au.mathworks.com,2005:Question/4067052018-06-21T07:01:02Z2018-06-21T10:16:05ZHow to make equal number of images in each class.? which is the best method for this.<p>Say i have different classes of images, but they are not equal in number to train. some class of images are in 1000's, some are in 100's, some are below 50 and 10. How i can make them equal.? Which is the best method for this.After that i need to do feature extraction. So if i have good number of images in each class i can train well i guess.</p>karthik khttps://au.mathworks.com/matlabcentral/profile/authors/11636146-karthik-ktag:au.mathworks.com,2005:Question/4066712018-06-20T23:00:29Z2018-06-21T10:09:55ZHow can I find the area (the position) below an axes? <p>Is there any way to find the area below an axes? In position parameters [pixels preferably]</p><p>Thanks</p>Stelios Fanourakishttps://au.mathworks.com/matlabcentral/profile/authors/10865530-stelios-fanourakistag:au.mathworks.com,2005:Question/4067252018-06-21T09:15:41Z2018-06-21T10:04:16ZWhich one is faster: trace(a' * b) or sum(sum(a .* b', 2))?<p>Hi all,</p><p>If I have 2 matrices with same size, I first perform SVD to each, then calculate the trace differently as follows:</p><pre class="language-matlab">clear; clc;
% this script tests what's the fastest way to compute trace with SVD
% vectors.
ma = rand(30000, 100); % large, rectangular matrices.
mb = rand(30000, 100);
</pre><pre class="language-matlab">[ua, sa, va] = svd(ma, 0);
[ub, sb, vb] = svd(mb, 0);
% case 1: trace(a' * b)
tic
for i = 1:1000
otptTr = trace((vb' * va) * sa' * (ua' * ub) * sb);
end
toc
% case 2: sum(sum(a.*b', 2))
tic
for i = 1:1000
otptSum = sum(sum(((vb' * va) * sa') .* ((ua' * ub) * sb)', 2));
end
toc
</pre><p>I'd like to know if these operations are repeated for many times, which one is faster? I thought case 2 would be faster, but my test results are:</p><pre class="language-matlab">Elapsed time is 8.242850 seconds.
Elapsed time is 8.267731 seconds
</pre><p>which is roughly the same.</p><p>Since trace only cares about the diagonal values, and the nth element in the diagonal is the scalar product of the nth row of A with the nth column of B, is there any ways faster by only computing the elements on the diagonal?</p>Xiaohan Duhttps://au.mathworks.com/matlabcentral/profile/authors/7807151-xiaohan-dutag:au.mathworks.com,2005:Question/4054912018-06-13T15:08:47Z2018-06-21T10:00:27Zhow to create a Matrix from a dat file<p>Attach below is my output(pfoutput.dat) file.</p><p>First i will like to have my codes recognize the bus number of my system. 14 for example as in the case below in row 1.</p><p>Secondly i will like my code to start reading or skip 5 lines after the stored line (***************power flow report*************) which is row 16.</p><p>Lastly i will like my codes to read only the rows start with "1,2,3...,14" skipping all row starting with "To-Bus" to produce a matrix of n rows and 7 columns , where n= number of bus system.</p><p>thanks for your help and time in advance</p>GUSTAF NJEIhttps://au.mathworks.com/matlabcentral/profile/authors/12908694-gustaf-njeitag:au.mathworks.com,2005:Question/4067062018-06-21T07:07:58Z2018-06-21T09:59:23ZResize figure changes position and dimension of some objects<p>I have some issues with positioning and the dimension for different kind of objects, for the following code.
When you resize the figure, you can see that the button and listbox have always the same size and position to each other.</p><p>I would like to set the position and dimension of the panel and axes like that, too.
I don´t want to get the objects resized, when the user is changing the figure size and I want to get a full screen at the beginning as well.</p><p>Is there any possibility to do that?</p><pre> function GUI()</pre><pre> close all</pre><pre> data = createData();
gui = createInterface();</pre><pre> %%
function data = createData()</pre><pre> data.Test_data = {'Test1','Test2','Test3', 'Test4'};
data.arrow_p1 = [0.5 1]; % Startpunkt x1,y1
data.arrow_p2 = [0 -1]; % Breite des Pfeils = 0 und Länge des Pfeils mit Richtung -1 (nach unten)</pre><pre> data.Dir_path = pwd;
assignin('base','data', data);</pre><pre> end</pre><pre> %%
function gui = createInterface()
% Gui creation</pre><pre> gui.Window = figure('Units','normalized','OuterPosition',[0 0 0.9 0.9],...
'Name','Test', ...
'NumberTitle', 'off','MenuBar', 'none');</pre><pre> % Menübar
gui.FileMenu1 = uimenu( gui.Window, 'Label', 'Datei' );
gui.FIleMenu5 = uimenu( gui.FileMenu1, 'Label', 'Beenden', 'Callback', @onExit );
gui.FileMenu2 = uimenu( gui.Window, 'Label', 'Speichern' );</pre><pre> % Panel</pre><pre> gui.panel = uipanel('Units','normalized','Title','Panel','FontSize',10,'Position',[.01 .5 .25 .5]);</pre><pre> % Checkbox</pre><pre> for k=1:4
gui.checkbox{k} = uicontrol('parent',gui.panel,'Style','checkbox','string',data.Test_data(1*k),...
'Position',[10 350-k*20 150 20]);
end</pre><pre> % Listbox</pre><pre> for s=1:5
gui.Listbox_{s} = uicontrol('Style','listbox','Position',[300+200*s 400 120 100],'Visible','On');
end </pre><pre> % Button</pre><pre> for x=1:5
gui.Button_{x} = uicontrol('Style','pushbutton','Position',[300+200*x 500 120 40]);
end </pre><pre> % Axes</pre><pre> gui.axes = axes('Outerposition',[.335 .65 .05 .1],'Visible','Off');</pre><pre> % Arrow</pre><pre> h=annotation('textarrow','String','Test Arrow in Axes '); %% arrow, doublearrow, textarrow
set(h,'parent', gui.axes, 'position', [data.arrow_p1,data.arrow_p2], ...
'HeadLength', 5, 'HeadWidth', 5, 'HeadStyle', 'vback2', ...
'Color', [0 0 0], 'LineWidth', 0.5);</pre><pre> end
%%</pre><pre> end</pre>Pi Heighthttps://au.mathworks.com/matlabcentral/profile/authors/8239001-pi-heighttag:au.mathworks.com,2005:Question/4067302018-06-21T09:55:40Z2018-06-21T09:55:40ZI am unable to find simdriveline in R2018 version<p>Can someone please tell me how to get simdriveline in 2018 version of MATLAB</p>Prince Sharmahttps://au.mathworks.com/matlabcentral/profile/authors/10420295-prince-sharmatag:au.mathworks.com,2005:Question/4062132018-06-18T18:46:46Z2018-06-21T09:53:16Z I would like to know 'the method to obtain intensity of an object in the image'. I required the output in terms of intensity values or contour plots. Suggest which image processing tool has to be used?<p>doubt in image processing</p>praseeja A Vhttps://au.mathworks.com/matlabcentral/profile/authors/13024816-praseeja-a-vtag:au.mathworks.com,2005:Question/4067292018-06-21T09:48:04Z2018-06-21T09:49:54ZI want to envelope the damped curve with an exponential function passing through the peak points. Can someone help?<p>X = A1*(exp(-alpha*t)).*cos(wd*t)+ A2*(exp(-alpha*t)).*sin(wd*t) is the equation of the damped curve with parameters as
t=0:0.000050:0.1;
A1 = 12.87701558;
A2 = -12.70012814;
alpha = 67.91641;
wd = 4770.680551</p><p>The equation of the enveloping curve is
I = Io * exp(-67.91641*t)
where Io is the peak values of the damped curve</p><p>I am attaching the image of damped curve as well as its enveloping curve through peak points.</p>Neha Sinhahttps://au.mathworks.com/matlabcentral/profile/authors/10701459-neha-sinhatag:au.mathworks.com,2005:Question/4066062018-06-20T16:28:35Z2018-06-21T09:45:18Zplease help me plotting the curve. Its working fine till second last line but not plotting the curve.<p>syms x A</p><p>theta=[0:10:360]</p><p>n=4.25</p><p>val1=3.271 %value of 6nU</p><p>val2=12.45481 %value of 12nw
J=(0.2728*(x.^3)-0.0592*x)*(10.^(-3))*0.055*(sind(theta)+(sind(2*theta)./(2*((18.0625-((sind(theta)).^2)).^(1/2)))))</p><p>G=val1*int((0.0682*(x.^4)-0.2951*(x.^2)+1.041).^(-2))</p><p>H=val2*J*int(x*((0.0682*(x.^4)-0.2951*(x.^2)+1.041).^(-3)))</p><p>K=A*int((0.0682*(x.^4)-0.2951*(x.^2)+1.041).^(-3))</p><p>y=0.055*((1-cosd(theta))+(n-sqrt(square(n)-(sind(theta)).^2)))</p><p>P=G+H+K</p><p>P=double(subs(P,(x),(y)))</p><p>fplot(theta,P)</p>Shalabh Singhalhttps://au.mathworks.com/matlabcentral/profile/authors/12921300-shalabh-singhaltag:au.mathworks.com,2005:Question/4067282018-06-21T09:45:00Z2018-06-21T09:45:00ZPareto front for 3-d scatter plot<p>Hello Everyone,</p><p>I have set of co-ordinates in 3-d space. I'm seeking the surface formed by the points around a certain point.I believe applying pareto front to the 3-d scatter plot will give the required surface. Please help me with the code</p>Vishal Hariharanhttps://au.mathworks.com/matlabcentral/profile/authors/11340310-vishal-hariharantag:au.mathworks.com,2005:Question/3920162018-04-01T20:09:54Z2018-06-21T09:40:49ZLibrary Compiler Tool Matlab Code To Java Code Load Function Problem<p>Hello,</p><p>I exported Matlab code to Java as a java lib. I use Matlab Library Compiler toolbox. I do succcesfully but when I call from Java this library, I got th following error in the Matlab.</p><pre class="language-matlab">Mdl.mat (varible name Mdl_subdisc) added in "Files required for your library to run" in Matlab Library Compiler toolbox.
</pre><p>Can you help me about error? Thanks in advance.</p><p>.m file:</p><pre class="language-matlab">function score = HUClassificationV11(Data_Set)
</pre><pre> Mdl_subdisc = classreg.learning.classif.ClassificationEnsemble.empty;
% ensembleSubspaceDisciriminant data_set is merged contains all data
% taken from HU PT
try
success ='model file is found'
load('Mdl.mat'); **%%%%%%% LINE 8 %%%%%%**
catch
error = 'model file is not found'
end</pre><pre> Data_Set = array2table(Data_Set);
% Convert to generic Data_Set annotation
for i = 1:1200
Data_Set.Properties.VariableNames{i} = strcat('Data_Set', num2str(i));
end
[labels, score] = predict(Mdl_subdisc, Data_Set) **%%%%% LINE 18 %%%%%**</pre><p><b>Complete error: in JAVA</b></p><pre class="language-matlab">Warning: Cannot load an object of class 'CompactClassificationDiscriminant':
Its class cannot be found.
> In HUClassificationV11 *(line 8)*
Struct contents reference from a non-struct array object.
</pre><pre class="language-matlab">Error in classreg.learning.ensemble.CompactEnsemble.predictOneWithCache (line 258)
</pre><pre class="language-matlab">Error in classreg.learning.ensemble.CompactEnsemble.aggregatePredict (line 181)
</pre><pre class="language-matlab">Error in classreg.learning.classif.CompactClassificationEnsemble/score (line 81)
</pre><pre class="language-matlab">Error in classreg.learning.classif.CompactClassificationEnsemble/predict (line 145)
</pre><pre class="language-matlab">Error in HUClassificationV11 *(line 18)*
</pre><pre class="language-matlab">Error is occured. Detail: Struct contents reference from a non-struct array object.
</pre>Volkan Ulutashttps://au.mathworks.com/matlabcentral/profile/authors/10461873-volkan-ulutastag:au.mathworks.com,2005:Question/4067172018-06-21T08:35:47Z2018-06-21T09:40:24ZHow to interpolate intermediate values?<p>I have an array with 110 values.
let say:</p><pre class="language-matlab">M1_allvalues = [1,2,10,-1,-2,..,-10, 1, 2..........,10]
</pre><p>I simply want to make the array to a size of 3600 values in it, by interpolating the values in between each array element. There would be approximately 32-33 values between each element to achieve 3600 values array.
For example:</p><pre class="language-matlab">Between 1 and 2 in the given array some 32 values, then the beginning would be:
newArray = [1, 1.03, 1.06, 1.09........,1.97, 2,......, 3,........, 110]
</pre><p>How do I do that?
I was thinking of this:</p><pre class="language-matlab">for i=1:length(M1_allvalues) - 1
newArray(i,1)= M1_allvalues(i,1): (32-33 vales): M1_allvalues(i + 1,1);
end
</pre><p>could you me some idea?</p>Jacky Johttps://au.mathworks.com/matlabcentral/profile/authors/6963000-jacky-jotag:au.mathworks.com,2005:Question/4067272018-06-21T09:39:56Z2018-06-21T09:39:56ZHow to implement a discrete transfer function from System Identification Toolbox in simulink ? <p>I have used the System Identification Toolbox to get a discrete transfer function of a system with a sample time of 60 seconds and I got these good results :</p><img src = "/matlabcentral/answers/uploaded_files/122207/ft_hx.png"><p>However when I implement this function in Simulink, the output of transfer function (legend : tf) is far from the measured output (legend : sim).</p><img src = "/matlabcentral/answers/uploaded_files/122208/ft_vs_sim.png"><p>I've used discrete ode3 solver with a 60s sample time and tried different initialization conditions.
I don't understand why the simulink output is so far from the measured data (I've already used System Identification Toolbox for easier system without noticing this difference).</p>catherine magarhttps://au.mathworks.com/matlabcentral/profile/authors/9154805-catherine-magartag:au.mathworks.com,2005:Question/4067142018-06-21T08:12:43Z2018-06-21T09:33:56ZCell array to Matrices<p>Dear Matlab users,
I have a cell array B 1x512 . now I want to divide every cell to a new matrix. So I will have 512 matrices.I prefer their names to be C1,C2...,C512. every "C" matrix is 10001x3 matrix.</p><p>I am using cell2mat option, but I want to write a loop which I cannot do it</p><pre> C1=cell2mat(B(1))</pre><p>thi is working just for one, I do not want to do it one-by-one.</p><p>Thanks in advance,</p>Fatemeh Aghapouraslhttps://au.mathworks.com/matlabcentral/profile/authors/10941650-fatemeh-aghapourasltag:au.mathworks.com,2005:Question/4038902018-06-04T11:08:31Z2018-06-21T09:29:35Zimporving the speed of parallel optimization<p>Hi, I am trying to optimize in parallel but the speed is increased just slightly by using parfor. Do you have any further recommendations? Thanks!</p><pre> parfor i = 1:M</pre><pre> options = optimset('MaxFunEvals',Inf,'MaxIter',10,...
'Algorithm','interior-point','Display','iter');
startTime = tic;
[x(:,i),fval(:,i)] = fmincon(@(x)revenue(price(1:N,1),ro,g,eff,x,N,k1,init_s(i),inFlow(:,i),alpha_par(i),b_par(i)),x0(1:2*N,i),A,b(:,i),Aeq,beq(:,i),LB(:,i),UB(:,i),[],options);
time_fmincon_parallel = toc(startTime);
fprintf('Parallel FMINCON optimization takes %g seconds.\n',time_fmincon_parallel);
end</pre>sensationhttps://au.mathworks.com/matlabcentral/profile/authors/6595643-sensationtag:au.mathworks.com,2005:Question/4065062018-06-20T08:38:51Z2018-06-21T09:29:14ZMatlab coder - When input a filename as input paremeter, how to define input types <p>Hello, I wonder how could I set the filename as a input parameter?
I am using Matlab coder to generate a c++ function, the input parameter is the filename of a image file. I called the parameter in "imread()".</p><p>When I use "Autodefine Input Types", the autodefined type is char(1x9) or char(1x:9), which is of course wrong because I can't promise that the length of other filename is smaller than 9.</p><p>Then I wanna change the input type to "string(1x1)", the app automatically add a sub-type, like shown in picture below.</p><img src = "/matlabcentral/answers/uploaded_files/122077/%E6%8D%95%E8%8E%B7.PNG"><p>According to the request of the app, this sub-type can only be defined as "char", so I choose char(1x1).</p><p>Then it goes wrong when generating trial code, saying "The filename or URL must be char vector."</p><p>I wonder how could I set the filename as a input parameter? Or if I use char(1xinf) as a input type, how should I define the input parameter in C++ program?(I tried char s[] but faild). Thank you!</p>Xuechu Xuhttps://au.mathworks.com/matlabcentral/profile/authors/12947729-xuechu-xutag:au.mathworks.com,2005:Question/4025262018-05-25T09:58:31Z2018-06-21T09:27:55Zcall function in fmicon optimization failing<p>Hi guys, I have 4 functions where each one is derived from previous one. When I call the last one (revenue.m) I got an error using fmincon. Any clue? I want to optimize in respect to x0 that is present in each function.
Many Thanks! Here is my code:</p><p>%% Total out flow equation
T = zeros([N,M]);
S=zeros([N,M]);
for i = 1:M</p><pre> R(:,i)=revenue(price(:,1),HH(:,i),ro,g,eff,x0(:,i),N,k1);
options = optimset('MaxFunEvals',Inf,'MaxIter',50,...
'Algorithm','interior-point','Display','iter');
tic
[x(:,i),fval(:,i)] = fmincon(@revenue,x0(1:2*N,i),A,b(:,i),Aeq,beq(:,i),LB(:,i),UB(:,i),[],options); %good
toc
end</pre><p>with revenue fun being:</p><pre> function R=revenue(price,HH,ro,g,eff,x0,N,k1)</pre><pre> R= -sum(price.*((HH*ro*g*eff).*x0(1:N))/k1);</pre><pre> end
% saved as revenue.m </pre><p>Error msg:</p><pre> Not enough input arguments.
Error in revenue (line 5)
R= -sum(price.*((HH*ro*g*eff).*x0(1:N))/k1);
Error in fmincon (line 535)
initVals.f = feval(funfcn{3},X,varargin{:});
Caused by:
Failure in initial objective function evaluation. FMINCON cannot continue.
end</pre>sensationhttps://au.mathworks.com/matlabcentral/profile/authors/6595643-sensationtag:au.mathworks.com,2005:Question/4055362018-06-13T19:35:43Z2018-06-21T09:27:40ZHow to model a system with independent clocks for HDL Code generation?<p>Hello,</p><p>I'm working on a HDL project that uses several independent, asynchronous clocks. Specifically, there is an external clock for the input logic, an internal clock for processing and another external clock for the output logic.</p><p>Even though it is my understanding that asynchronous clocks can't be modelled in Simulink directly, the whole system should be contained in a single Simulink model for simulation and verification.</p><p>I think that the synchronisation logic between the different clock domains needs to be added by hand in Xilinx Vivado after code generation. I have attached a screenshot of the model's structure for clarification.</p><p>What is the best way to generate code for such a system? Is my general approach correct? How do I get HDL Coder to let me supply the different subsystems with different clocks?</p><p>Any help with this is appreciated, thanks in advance.</p><p>Felix</p><img src = "/matlabcentral/answers/uploaded_files/121364/schema.png">Felix Schneiderhttps://au.mathworks.com/matlabcentral/profile/authors/7842297-felix-schneidertag:au.mathworks.com,2005:Question/4067262018-06-21T09:27:00Z2018-06-21T09:27:00ZHow to implement discrete transfer function from System Identification Toolbox in Simulink ?<p>I have used the System Identification Toolbox to find a discrete transfer function with a 60seconds sample time and I got these good results :</p><img src = "/matlabcentral/answers/uploaded_files/122201/ft_hx.png"><p>however when I implement the corresponding transfer function in simulink, transfer function output (legend : tf) is very far from working data (legend : sim).</p><img src = "/matlabcentral/answers/uploaded_files/122202/ft_vs_sim.png"><p>My sample time is 60s in simulink, I'm using discrete solver ode3. I've tried to change also the initial condition of transfer function but it has not worked.</p>catherine magarhttps://au.mathworks.com/matlabcentral/profile/authors/9154805-catherine-magartag:au.mathworks.com,2005:Question/4063282018-06-19T11:06:47Z2018-06-21T09:26:55ZHow to use two colormaps (of different size) in same figure with one axes?<p>I'm using the mapping toolbox and quivermc function (has to be downloaded seperatly) to display atmospheric data. I want to show a contourfm with a colormap that has only three colors; on top of that should be a quivermc plot with the colormap jet and lots of different colors; I only want the second colormap displayed as a colorbar;</p><pre class="language-matlab">figure ('Color', 'w');
latlim = [min(data.lat) max(data.lat)]; % - Norweger [30 70]
lonlim = [min(data.lon) max(data.lon)]; % - Norweger [-65 10]
ax = axesm('lambertstd', 'MapLatLimit',latlim,'MapLonLimit',lonlim); % - Lambert conic projection; Norweger Bereich
axis off;
framem on; % - turns frame on
framem('FLineWidth', .5, 'FontSize', 8, 'LabelRotation', 'off',...
'MLabelLocation', [-60 -40 -20 0], 'PLabelLocation',[30 40 50 60 70]); %'LabelFormat', 'signed',
gridm on; % - turns grid lines on;
gridm('MLineLocation', [-60 -50 -40 -30 -20 -10 0], 'PlineLocation', [30 35 40 45 50 55 60 65 70]);
mlabel on; % - turns meridian labelling on;
plabel on; % - parallel labeling of current map axes
</pre><pre> %make my own colormap
colors = [ 1, 1, 1;
0.322, 0.557, 0.376;
0.031, 0.427, 0.188];
colormap(colors);</pre><pre> [C, ~] = contourfm(data.lat, data.lon, RH (:,:), 'LevelList', [75 90], 'LineColor', 'none');
colormap(gca, colors);
set (gca, 'Clim', [60 105]); hold on;
% change colormap to jet
colormap(jet);
[h, qcb]= quivermc(latnew, lonnew, squeeze(data.UU(find(data.level == 700),:,:)), ...
squeeze(data.VV(find(data.level == 700),:,:)), 'density', 5, 'arrowstyle', 'tail', ...
'units', 'm s^{-1}', 'colormap', jet, 'colorbar', 'on', 'AutoScalefactor', 3 );
hold on; </pre><p>the result should look like this (but in the same figure and on top of each other):</p><img src = "/matlabcentral/answers/uploaded_files/121956/1.jpg"><img src = "/matlabcentral/answers/uploaded_files/121958/2.jpg"><p>I already tried https://de.mathworks.com/matlabcentral/answers/101346-how-do-i-use-multiple-colormaps-in-a-single-figure these possible solutions but couldn't make it work.</p>Carmen Schüsslinghttps://au.mathworks.com/matlabcentral/profile/authors/12886358-carmen-schusslingtag:au.mathworks.com,2005:Question/4063412018-06-19T12:00:51Z2018-06-21T09:23:47ZSir, am having the four mat files, which of two contains features from minutie and other two contains feature from invarient moment, can i make fusion of those features by combining it then how?<p>Sir, am having the four mat files, which of two contains features from minutiae and other two contains feature from invariant moment, can i make fusion of those features by combining it then how?</p>Balaji M. Sontakkehttps://au.mathworks.com/matlabcentral/profile/authors/7099670-balaji-m-sontakketag:au.mathworks.com,2005:Question/4067182018-06-21T08:43:28Z2018-06-21T09:23:34ZStrange Cell Array error<p>Hello.
I have a cell array in a uitable that I want to find the min of the columns 2,3,4,5 - and for each column, extract the z position from the file name that corresponds to that minimum.</p><img src = "/matlabcentral/answers/uploaded_files/122198/im126.png"><pre> for h=1:4 %first column is filename, so start at 2
h
data(:,h+1)
class(data)
c2=str2num(cell2mat(data(:,h+1))) %Select column fwhmH=2 etc.
c2min=min(c2(:));
c2idx=find(c2==c2min);
text=cell2mat(file(c2idx));
C = strsplit(text,'zPos_');
class(C);
C=cell2mat(C(2));
D=strsplit(C,'.tif')
data2=horzcat(data2,D(1))
end
set(handles.uitable2,'data',data2)</pre><p>However, on the 3rd loop (h=3), for the following code</p><pre> h
data(:,h+1)
class(data)
c2=str2num(cell2mat(data(:,h+1))) %Select column fwhmH=2 etc. </pre><p>I get the following output and error</p><pre class="language-matlab">h =
</pre><pre> 3.00</pre><pre class="language-matlab">ans =
</pre><pre> 3×1 cell array</pre><pre> {'8317' }
{'10974'}
{'14623'}</pre><pre class="language-matlab">ans =
</pre><pre> 'cell'</pre><pre class="language-matlab">Error using cat
Dimensions of matrices being concatenated are not consistent.
</pre><pre class="language-matlab">Error in cell2mat (line 83)
m{n} = cat(1,c{:,n});
</pre><p>I can't understand why as on the 1st & 2nd loop that correctly works, the data is of the same type - i.e. cell array</p>Jasonhttps://au.mathworks.com/matlabcentral/profile/authors/1217570-jasontag:au.mathworks.com,2005:Question/4067032018-06-21T06:40:14Z2018-06-21T09:21:22ZMoving window in a matrix<p>I have a matrix (signal)with size 5X3600.I want to do read the signal in time windows of T = 8 seconds long with incremental steps of S = 2 seconds for the entire duration of the signal,ie,3600.Row should be same ,only column should change with 2 sec duration,ie,column should be 1:8,then 3:11 and so on</p>RPhttps://au.mathworks.com/matlabcentral/profile/authors/3952674-rptag:au.mathworks.com,2005:Question/4067212018-06-21T08:46:53Z2018-06-21T09:19:58Zsave result of each iteration in a joint table<p>Hi, I am trying to save the results of each iteration as one joint table. However I got only the last one. Any hint? Thanks</p><pre> for j=1:d %
% some fun to calculate and get results.mat
load results.mat % obsData simData at each loop d
T(:,:)= table(obsData(:),simData(:));
end</pre>Marko Adamovichttps://au.mathworks.com/matlabcentral/profile/authors/11071892-marko-adamovictag:au.mathworks.com,2005:Question/4056862018-06-14T14:01:21Z2018-06-21T09:13:46ZDownload Bug polyspace/configure_maci64_1517898598.enc:<p>Hallo,</p><p>every time I try to download the Matlab for the installation, the same error appears "polyspace/configure_maci64_1517898598.enc:".</p><p>Which is the reason for this error and how can I fix it? At my first try, the Download stopped at nearly 40% after losing the connection with the internet. After it, I can't download a single file, before the bug appears.</p><p>I Use a Macbook 2013 which runs on OS X Yosemite 10.10.5. I'm trying to install Matlab Version R2018a.</p><p>Kind Regards</p><p>Domenic</p>Domenic Ixhttps://au.mathworks.com/matlabcentral/profile/authors/12984088-domenic-ixtag:au.mathworks.com,2005:Question/4066992018-06-21T06:10:35Z2018-06-21T09:11:39Zread a .ssv file<p>Hello I want to read a .ssv format file in MATLAB and put it in a matrix The file with format .ssv contains 1500 lines and 24 columns Help me please ...For example, this code did not answer. and I dont know what to do</p><pre class="language-matlab">function [training_set, test_set] = read_data(train_path, test_path)
train_file = fopen(train_path);
</pre><pre> training_set = cell2mat(textscan(train_file, '%f %f %f %f'));</pre><pre> fclose(train_file);</pre><pre> % open the test data and save to a matrix
test_file = fopen(test_path);</pre><pre> test_set = cell2mat(textscan(test_file, '%f %f %f %f'));</pre><pre> fclose(test_file);</pre>f moradihttps://au.mathworks.com/matlabcentral/profile/authors/11909153-f-moraditag:au.mathworks.com,2005:Question/3156722016-12-06T15:17:14Z2018-06-21T09:10:14Zhow can i interface MP150 BIOPAC with matlab to read the data?<p>I am working on a project to do real time analysis of brain signal via EEG. I am using BIOPAC hardware STP100-C and MP150. I need to read the data via MP150 in real time and possibly record it in Matlab. Is there way to do this???
Please help!!</p>rishav rajhttps://au.mathworks.com/matlabcentral/profile/authors/9111336-rishav-rajtag:au.mathworks.com,2005:Question/3553702017-09-06T08:25:37Z2018-06-21T09:09:40Z"Unable to allocate memory for an incoming image frame due to insufficient free physical memory." error for skeleton tracking with Kinect v2 <p>I was trying to do skeleton tracking with Kinect v2 but am getting "Unable to allocate memory for an incoming image frame due to insufficient free physical memory." when running the second time. Restarting the matlab window enables to solve this problem for one time. again while am running the same code for more than one time the same error comes.
The error screenshot is attached herewith. Please anyone if possible let me know how to resolve this error.</p><img src = "/matlabcentral/answers/uploaded_files/87186/gfdd.jpg">PARIKSHIThttps://au.mathworks.com/matlabcentral/profile/authors/3090095-parikshittag:au.mathworks.com,2005:Question/4061612018-06-18T13:25:57Z2018-06-21T09:08:51ZUndefined function 'predict' for input arguments of type 'table' for Python package (with Matlab Compiler).<p>I am getting the error "Undefined function 'predict' for input arguments of type 'table'" when I try to execute the function that I packaged for Python. The function should predict based on a trained SVM model (edit: I used 'templateSVM' and 'fitcecoc' functions). I am sure my inputs are all correct, the input is not a table format, it is a matrix of type double, all of the necessary dimensions of the matrix are correct too. The function works when I run it from Matlab directly, but fails when I call it from Python, giving me the error above. Could this be a licensing issue? Although I read that with application deployment of Statistics and Machine Learning Toolbox functionality no additional licenses are required if you used command line functions.</p>AIhttps://au.mathworks.com/matlabcentral/profile/authors/6120971-aitag:au.mathworks.com,2005:Question/4067242018-06-21T09:05:02Z2018-06-21T09:05:02ZHow to add icon to sl_action_schema in sl_customization?<p>Hello Mathworks Team,
how can I add an icon to an sl_action_schema in sl_customization?
This is what I tried so far:</p><pre class="language-matlab">function schema = getItemMyEntry(callbackInfo)
schema = sl_action_schema;
schema.label = 'MyEntry';
schema.icon = 'MyIcon.png';
schema.callback = @myEntryCallback;
end
</pre><p>The entry appears in the Simulink menu, but without an icon. I tried icons of size 16x16 and 24x24 with relative and absolute path. Tried only png so far (for example the help16x16.png file from the MATLAB installation folders).</p>Hartmut Pohlheimhttps://au.mathworks.com/matlabcentral/profile/authors/3437279-hartmut-pohlheimtag:au.mathworks.com,2005:Question/2739042016-03-16T20:25:17Z2018-06-21T09:00:19ZNaN/Inf/Complex value warning using "fit"<p>Hi all,</p><p>I'm interpolating between points using "fit" and get the warning</p><pre class="language-matlab">Warning: NaN, Inf, or complex value detected in startpoint;
choosing random starting point instead.
> In curvefit.attention.Warning/throw (line 30)
In fit>iFit (line 299)
In fit (line 108)
In fit_test (line 12)
</pre><p>The things is, (I'm pretty sure) there is no NaN, Inf, or complex value involved. Also weird, the fit seems to be different every time I execute the code (and goes completely haywire from time to time). If the first row in the data is removed, the warning disappears.</p><p>I included a code snippet that replicates my problem:</p><pre class="language-matlab">clear
close
</pre><pre class="language-matlab">% data
data = [1,4.26993;2,3.316751;3,3.130543;4,2.785851;5,2.462480;6,2.220899;7,1.991443;8,1.713285;9,1.591862;10,1.426485;11,1.329915;12,1.212978;13,1.163305;14,1.099329;15,1.042767;16,0.9620282;17,0.9086622;18,0.8804317;19,0.8365277;20,0.8281681;21,0.7897473;196,0.08825890;197,0.08764152;198,0.08784707;199,0.08867170;200,0.09054118];
</pre><pre class="language-matlab">% if first row is removed, no warning appears
% data(1,:) = [];
</pre><pre class="language-matlab">% fit two-term exponential function to data
data_fit = fit(data(:,1),data(:,2),'exp2');
</pre><pre class="language-matlab">% plot fitted data and curve
figure
plot(data_fit,data(:,1),data(:,2),'predfunc')
</pre><p>Any ideas? Thanks!</p>Fabshttps://au.mathworks.com/matlabcentral/profile/authors/4010424-fabstag:au.mathworks.com,2005:Question/4067232018-06-21T08:59:44Z2018-06-21T08:59:44Z[Reference Design] Define and Register Custom Board- Error in Step 4.4<p>Hi, I have defined and have registered a custom Board as a reference design method (https://it.mathworks.com/help/hdlcoder/examples/define-and-register-custom-board-and-reference-design-for-zynq-workflow.html).
The hardware is developed in Vivado Xilinx.
Only the last step 4.4 fails!
The step 4.3 works and gives me the following log:</p><p>Task "Build FPGA Bitstream" successful.
Generated logfile: hdl_prj\hdlsrc\schema_1\workflow_task_BuildFPGABitstream.log
Running embedded system build outside MATLAB.
Please check external shell for system build progress.
The generated bitstream file is located at: hdl_prj\vivado_ip_prj\vivado_prj.runs\impl_1\system_top_wrapper.bit
Generate an HDL Workflow Command-Line Interface script to program the target device: hdlworkflow_ProgramTargetDevice.m.</p><p>While the step 4.4 doesn't work and give me the following problem</p><p>Failed Program target FPGA device.
Task "Program Target Device" unsuccessful. See log for details.
Generated logfile: hdl_prj\hdlsrc\schema_1\workflow_task_ProgramTargetDevice.log
Downloading target FPGA device configuration over Ethernet to SD card ...
Cannot identify hdl_prj\vivado_ip_prj\vivado_prj.runs\impl_1\system_top_wrapper.bit. No such file or directory.</p><p>I note that in the step 4.3 the file system_top_wrapper.bit is present in the directory, while in the step 4.4 the file disappeares!
What is the problem? Can you help me?
Thank thank thank you.</p>Giacomohttps://au.mathworks.com/matlabcentral/profile/authors/3234548-giacomotag:au.mathworks.com,2005:Question/4067222018-06-21T08:56:13Z2018-06-21T08:57:54ZHow to install a MATLAB Toolbox from a *.enc file<p>Hello everyone,</p><p>I am trying to install a specific Toolbox (Real-Time Workshop) into an old MATLAB version (R14SP2). I have a *.enc file with the Toolbox, but when I launch the installation it does not appear on the Toolbox list.</p><p>Would anyone know how to solve this problem?</p><p>Thank you in advance.</p>Ignacio Izardhttps://au.mathworks.com/matlabcentral/profile/authors/6989899-ignacio-izardtag:au.mathworks.com,2005:Question/4063722018-06-19T14:28:01Z2018-06-21T08:51:24ZToo much calculus time on 'lsqcurvefit' + 'fsolve'<p>Good afternoon everybody,</p><p>I am working with a code that combines 'fsolve' and 'lsqcurvefit' to calculate the parameters, k(1), k(2) and k(3), that better fits my function, called 'Iteor', to my experimental data, (texp, Iexp):</p><pre class="language-matlab">rteor=@(k,r) fsolve(@(r) arrayfun(@(R,T) FC.*integral(@(x) exp(-a./(x.*log(x))), 1, R)-(T-(.001.*k(1))),r,texp), inpts, options);
Iteor=@(k,r) ((.01.*k(2)./FC).*(rteor(k,texp)).*exp(a./(rteor(k,texp)).*log(rteor(k,texp))))+(Vo./(100.*k(3).*log(rteor(k,texp))));
k = lsqcurvefit(Iteor, x0, texp, Iexp,[],[],options);
</pre><p>The problem is my experimental data are 22000 points large, and the calculus takes too much time. I'm working on a Intel Core i7 4.00 GHz and 32.0 GB. With FORTRAN the process is much faster... Is there any way to reduce the calculus time without eliminating initial experimental points ?</p><p>Thank you so much !!</p>Sergio Quesadahttps://au.mathworks.com/matlabcentral/profile/authors/12946816-sergio-quesadatag:au.mathworks.com,2005:Question/4066252018-06-20T18:08:34Z2018-06-21T08:33:12ZCreate uncompressed movie from sequence of 11-bit grayscale images<p>Hello,
I have a series of images from a custom sensor whose output is 11-bits. I get a series of tif images out of my software and would like to import them into MATLAB, manipulate them, and write them out to an uncompressed mj2 video stream. I'm confused by the requirements of the video writer. I have converted my sequence of images into uint16 in a MxNx1xK array, which the video writer should take. I'm not sure why the singleton dimension is required. I get nothing but black video out. Here is my code:</p><pre class="language-matlab">workingDir = 'R:\';
frameRate = 60;
imageBits = 11;
</pre><pre class="language-matlab">% sort and load all image files
imFiles = dir('*.tif');
</pre><pre class="language-matlab">[~, reindex] = sort( str2double( regexp( {imFiles.name}, '\d+', 'match', 'once' )));
imFiles = imFiles(reindex);
</pre><pre class="language-matlab">% read one file to get image size information
img = imread(imFiles(1).name);
</pre><pre class="language-matlab">imageSet = uint16(zeros(size(img,1),size(img,2),1,length(imFiles)));
</pre><pre class="language-matlab">%% Create image data set as 4D array. Frames are in the 4th dimension
for n = 1:length(imFiles)
img = imread(imFiles(n).name);
imageSet(:,:,1,n) = uint16(img);
end
</pre><pre class="language-matlab">%% write video to file
% create video container
outputVideo = VideoWriter(fullfile(workingDir,'videoSequence.mj2'),...
'Archival');
outputVideo.MJ2BitDepth = imageBits;
outputVideo.FrameRate = frameRate;
open(outputVideo);
</pre><pre class="language-matlab">% write image sequence to video
writeVideo(outputVideo, imageSet);
</pre><pre class="language-matlab">% finish the video file
close(outputVideo);
</pre><pre class="language-matlab">% load and play the video file
implay(fullfile(workingDir,'videoSequence.mj2'));
</pre>Preston Manwaringhttps://au.mathworks.com/matlabcentral/profile/authors/12735181-preston-manwaringtag:au.mathworks.com,2005:Question/4067162018-06-21T08:14:41Z2018-06-21T08:29:13ZFinding acceleration using ODE45.<p>I am solving a set of equations of motion using ODE45. ODE45 works perfectly to give me the displacement and velocity of the moving object. However, I would like to calculate one of the force components and for that I need the acceleration. How Should I go to work to find the acceleration from ODE45.</p>Philip Bothmahttps://au.mathworks.com/matlabcentral/profile/authors/11241669-philip-bothmatag:au.mathworks.com,2005:Question/4065252018-06-20T10:11:12Z2018-06-21T08:20:27ZImporting coordinates from excel and making points.<p>Hello. I need to import 3D coordinates from excel to matlab and make points in matlab from those coordinates, I have three columns for each X, Y and Z coordinate. Thanks for help</p>Matija Kosakhttps://au.mathworks.com/matlabcentral/profile/authors/13043154-matija-kosaktag:au.mathworks.com,2005:Question/4058322018-06-15T10:05:29Z2018-06-21T08:18:26ZPlot data from simulink<p>Hi, I'd like to know if I can plot two different series from simulink in one single 3d plot.</p><p>From simulink I'm having the following for a 300s simulation:</p><img src = "/matlabcentral/answers/uploaded_files/121593/Simulink.jpg"><p>I want the Bit Angular Displacement to be the Z axis. Is there a way to do it?</p><p>Thanks.</p>Carlos Castañedahttps://au.mathworks.com/matlabcentral/profile/authors/12934154-carlos-castanedatag:au.mathworks.com,2005:Question/4067152018-06-21T08:14:03Z2018-06-21T08:14:03Zhow to find the blood vessel bends for segmentation of optic cup?<p>I am working with retinal fundus image. I have extracted the blood vessel from original images and skeletonise the image, also removed spurs. Now I wanted to identify the blood vessel bends for segmenting the optic cup region. I have tried by finding out the radius of curvature but i failed to find the appropriate bends.So please help me to find out the bends in the blood vessel which i have extracted with code snippets. below is the image of the extracted blood vessel</p><img src = "/matlabcentral/answers/uploaded_files/122194/vessel.jpg">shrinidhi hhttps://au.mathworks.com/matlabcentral/profile/authors/10813103-shrinidhi-htag:au.mathworks.com,2005:Question/4061422018-06-18T11:26:56Z2018-06-21T08:09:37ZHow to determine the centroid of this fan(triangle) where the coordinates of one of the vertices is only known and the distance is also known? <p>I am not getting the centroid correctly. Please check the code.</p><pre class="language-matlab">x=[3];
y=[3];
r=[2];
delta=pi/3;
theta=2*pi*0.4;
si=size(x);
for i=1:si(2)
theta2 = theta + delta;
t = linspace(theta,theta2);
A = x(i) + r(i)*cos(t);
B = y(i) + r(i)*sin(t);
x_cen = mean(A)
y_cen = mean(B)
plot([x(i),A,x(i)],[y(i),B,y(i)],'b-',x_cen,y_cen,'ro')
axis([0 10 0 10]);
end
</pre>Aida Joneshttps://au.mathworks.com/matlabcentral/profile/authors/12966791-aida-jonestag:au.mathworks.com,2005:Question/4067132018-06-21T08:09:31Z2018-06-21T08:09:31Zsuperimposing contour over geoshow with different colormap<p>Hello,
I am using geoshow() with grayscale to plot Brightness temperature(BT) over Indian Region. But if I superimpose contour of BT geoshow, it does nothing. Is there anyway to plot geoshow and contour at the same time and with different colors.
I have two datasets of BT. One I want to use with geoshow and other(with some eliminated values) with contour</p><img src = "/matlabcentral/answers/uploaded_files/122191/geoshow_bt.PNG"><img src = "/matlabcentral/answers/uploaded_files/122192/contour_bt.PNG">Kavita Navriahttps://au.mathworks.com/matlabcentral/profile/authors/10552635-kavita-navriatag:au.mathworks.com,2005:Question/4065892018-06-20T15:22:02Z2018-06-21T08:06:04ZHow to improve a Thz image quality ?<p>Hello everyone,</p><p>I'd like to know how to improve the image that comes from a terahertz camera with matlab ?
the image is linked, I also have a video, can I work on the video to improve the image?
Thanks in advance</p>newport portnewhttps://au.mathworks.com/matlabcentral/profile/authors/13044640-newport-portnewtag:au.mathworks.com,2005:Question/4063232018-06-19T10:38:08Z2018-06-21T08:00:48ZCan Integrate a function of of displacement with time?<p>F =@(x1, x2) c.Ab.*(c.P0.*(c.V0./(c.Ab.*(x1 + x2))).^c.gam1 - c.Pa);</p><p>x1 and x2 are both matrices with distances. I also have a matrice of time
corresponds with the distance matrices. I would like to integrate this function
with time. Can this be done?</p>Philip Bothmahttps://au.mathworks.com/matlabcentral/profile/authors/11241669-philip-bothmatag:au.mathworks.com,2005:Question/3429822017-06-02T09:43:12Z2018-06-21T07:59:17ZTouchscreen inputs may be too transient to be captured by repetitively checking mouse status ?<p>Hello, experts.</p><p>I'm using Psychtoolbox.
I usually wait for and detect a mouse input like this:</p><pre class="language-matlab">while true
[x, y, button] = GetMouse ;
if any(button)
break
end
end
</pre><p>And it works fine with mouse.
But when I run this with the touchscreen of Microsoft Surface,
I often have to poke several times with my finger to input a click.
The mouse works fine with my code on Surface,
and the touchscreen works fine in all Windows applications on Surface except when running my code.</p><p>I doubt that it's because when I poke the touchscreen,
the effect equals a very brief mouse click on that point.
Sometimes the duration of the click includes the time when the function GetMouse runs,
and a click would be received by my code.
But sometimes the duration of the click doesn't include the time when the function GetMouse runs,
so my code does not detect the click.</p><p>Is my guess correct?
If not, what might the cause be?
Could any of you experts please tell me how can I detect inputs on touchscreen sensitively?
Thank you a lot if you help!</p>bisconecthttps://au.mathworks.com/matlabcentral/profile/authors/1737862-bisconecttag:au.mathworks.com,2005:Question/4066702018-06-20T22:59:16Z2018-06-21T07:58:49ZNaN and Inf error when using "fit"<p>Does anyone know why this error occurs when "fit" is called? My data contain no NaN or Inf.</p><p>Warning: NaN, Inf, or complex value detected in startpoint;
choosing random starting point instead.
> In curvefit.attention.Warning/throw (line 30)
In fit>iFit (line 299)
In fit (line 108)
In MyCode (line 47)
>></p>J.S.https://au.mathworks.com/matlabcentral/profile/authors/12937214-j-stag:au.mathworks.com,2005:Question/4067122018-06-21T07:57:45Z2018-06-21T07:57:45Zapplying multiple colormaps on one barchart using a for loop<p>I have one set of data in a barchart which I wish to assign 4 different colormaps to if possible. in the matrix, I have R1 (blue), R2-11 (bone), R12 (red), R13-22 (copper) but im unsure how to assign these colours and was hoping to use a for loop with if statements to do it.</p>Jessica Boguszhttps://au.mathworks.com/matlabcentral/profile/authors/12987572-jessica-bogusz