https://se.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2017-05-30T03:26:27Ztag:se.mathworks.com,2005:Question/3424482017-05-30T02:37:32Z2017-05-30T03:26:27ZI am trying to do a 2d Gaussian fit but my code doesn't work. It doesn't seem to do anything. It gives the initial guess values as the ouput with changing one of the parameters only. Below is my code.<p>p0=[180 150 30520 10 15 15];</p><p>I=imread('filename.png');</p><p>[m,n]=size(I);</p><p>[X,Y]=meshgrid(1:n,1:m);</p><p>x(:,1)=X(:);</p><p>x(:,2)=Y(:);</p><p>ft=I(:);</p><p>f=im2double(ft);</p><p>g = @(p,x) p(4)+p(3)*exp(-((x(:,1)-p(1))/sqrt(2)*p(5)).^2-((x(:,2)-
p(2))/sqrt(2)*p(6)).^2);</p><p>options=optimset('TolX',1e-8);</p><p>p=lsqcurvefit(g,p0(k,:),x,f,[],[],options);</p><p>for i=1:256</p><p>for j=1:320</p><p>G(i,j)=p(4)+p(3)*exp(-((X(i,j)-p(1))/(sqrt(2)*p(5)))^2)*exp(-((Y(i,j)-
p(2))/(sqrt(2)*p(6)))^2);</p><p>end</p><p>end</p><p>figure();</p><p>ax=subplot(2,2,1);</p><p>ax=imagesc(I);</p><p>colorbar;</p><p>bx=subplot(2,2,2);</p><p>bx=imagesc(G);</p><p>colorbar;</p><p>dx=subplot(2,2,3);</p><p>for i=1:256</p><p>for j=1:320</p><p>H(i,j)=p0(k,4)+p0(k,3)*exp(-((X(i,j)-p0(k,1))/(sqrt(2)*p0(k,5)))^2)*exp(-((Y(i,j)-
p0(k,2))/(sqrt(2)*p0(k,6)))^2);</p><p>end</p><p>end</p><p>dx=imagesc(H);</p><p>colorbar;</p><p>% H is a guess fit using initial parameters p0 while G is the actual fit. I am
getting the same thing for both with changed offsets nothing else.</p>Pritam Priyadarsihttps://se.mathworks.com/matlabcentral/profile/authors/10402797-pritam-priyadarsitag:se.mathworks.com,2005:Question/3422852017-05-28T20:19:01Z2017-05-30T03:26:00ZWhy I cannot plot anything?<p>I just installed the trial /linux version/ and every time I try to plot something, eg.</p><pre class="language-matlab">Trial>> x=0:20/pi:2*pi;
y=sin(x);
plot(x,y)
</pre><p>What's wrong?</p><p>program hangs up.</p>Olga Lisowskahttps://se.mathworks.com/matlabcentral/profile/authors/10395772-olga-lisowskatag:se.mathworks.com,2005:Question/3424502017-05-30T03:25:28Z2017-05-30T03:25:28ZHow to set the "Receive delay" in error rate calculation module？<p>I'm trying to built a Bluetooth system by simulink，but a problem occured to me，which I can't correctly set the "Receive delay" in error rate calculation module.
Actually，I know there is a “Bluetooth Frequency Hopping”model given by matlab，and the parameter in Receive delay is correct，but I want to know how the parameter is calculated and if there are some principles I can follow？</p>ruiqi liuhttps://se.mathworks.com/matlabcentral/profile/authors/10402924-ruiqi-liutag:se.mathworks.com,2005:Question/3424212017-05-29T19:28:47Z2017-05-30T03:08:42ZHow to know how points are from the same line?<p>I have set of points. I want to check how many of them belong to the same line or the end coordinates of each line.</p><p>For example I have matrix A= [1 2; 3 4; 5 6] and I want to check the above.</p><img src = "/matlabcentral/answers/uploaded_files/79066/untitled.jpg"><p>For example i need to know about 5 points of the four different lines. (starting or end of each of the four)</p>Ahmad Adeehttps://se.mathworks.com/matlabcentral/profile/authors/9148595-ahmad-adeetag:se.mathworks.com,2005:Question/3424452017-05-30T01:48:16Z2017-05-30T03:01:43ZHow do I seperate two columns of data into 12 different variables based on the number from the first column? <p>I have a variable with two columns, the first column are numbers that correspond to parameters for an experiment (there are 12 unique parameters total called "speed"), the second column is my raw data. I need to seperate the raw data into 12 different variables based on the numbers from the first column.</p><p>One of the parameters is a speed of 4... I pretty much want to tell matlab "If Column one = 4, the number next to 4 will go into a variable called speed4" Is there anyway to do this???</p>Marissa Holdenhttps://se.mathworks.com/matlabcentral/profile/authors/8304524-marissa-holdentag:se.mathworks.com,2005:Question/3424492017-05-30T02:59:04Z2017-05-30T02:59:04ZHow to write function to do the following decomposition's: non-controllable realization into controllable and un-controllable subsystem terms. repeat for observable<p>Then i have to Test these programs by constructing the following examples:
(i) a fourth order realisation with two states controllable and two states un-
controllable (2.5 marks)
(ii) a fourth order realisation with two states observable and two states un-
observable (2.5 marks)</p>ERica Hohttps://se.mathworks.com/matlabcentral/profile/authors/10265016-erica-hotag:se.mathworks.com,2005:Question/3424472017-05-30T02:37:22Z2017-05-30T02:37:22ZReferences for the Graph and Network Algorithms package?<p>Like a similar question before, I cannot find references to the algorithms used in some of the graph theory routines. For instance, I have tried to find exactly how you determine the connected components of a graph. This leads to the function connectedComponents(G), which you cannot find anywhere in the source material.</p><p>So, could you please provide a full set of references to the algorithms you are employing for the graph theory package? For that matter, in general, could you always provide references to the algorithms that MathWorks uses across the board for any of its algorithms.</p><p>I do understand if some of your code is proprietary and as such a "trade secret", in which case, a simple statement to that effect would help those of us publishing scientific results based on Matlab output.</p><p>Thank you for your time,
Kevin Mcilhany
US Naval Academy</p>Kevinhttps://se.mathworks.com/matlabcentral/profile/authors/186973-kevintag:se.mathworks.com,2005:Question/3424432017-05-30T01:35:37Z2017-05-30T02:37:14ZI wrote a function which is pretty simple but when I call it gives errors<p>FUNCTION CODE:</p><pre> function [v]=displacement(x,d_1,d_2,phi_1,phi_2,L)
a=[(2/L^3)*(d_1-d_2)+(1/L^2)*(phi_1+phi_2)].*x.^3;
b=[(-3/L^2)*(d_1-d_2)-(1/L)*(2*phi_1+phi_2)].*x.^2;
c=phi_1+d_1;
[v]=a+b+c</pre><p>MATLAB CODE:</p><pre> %DATA
d_1=0,d_2=0,phi_1=0,phi_2=0.0741;L=800;
x=[0:10:800];
v=@displacement([0:10:800];0;0;0;0.0741;800)
fplot(v,x)
xlabel('Position Along Length');
ylabel('Displacement Function');</pre>Asim Gillanihttps://se.mathworks.com/matlabcentral/profile/authors/10256190-asim-gillanitag:se.mathworks.com,2005:Question/3424392017-05-30T00:41:18Z2017-05-30T02:32:03ZHow can I plot Rankine Oval by using for statement??<p>By using contour fun. I can plot Rankine Oval function easily. But I want to describe by taking 'for' statement. How can I plot Rankine Oval by using for statement??</p><p>[source code containing 'contour']
[x,y] = meshgrid(-3:.01:3);
m=1;
a=1;
U=1;
psi = U*y+m*atan2(y,x+a)-m*atan2(y,x-a);
contour(psi,[-3:.1:3])</p>JONGJU Kimhttps://se.mathworks.com/matlabcentral/profile/authors/10394233-jongju-kimtag:se.mathworks.com,2005:Question/3424422017-05-30T01:29:37Z2017-05-30T02:25:06ZHow do I pick all the elements of a table, X number of times, without replacement?<p>I have a table consisting of 50 elements - it is a 50 x 2 table wherein each row represents a point location (in terms of X and Y coordinates). How do I pick these 50 points, 20 different times, in a random order?
To make myself more clear, I need each of these 50 different points (the X,Y coordinate pairs) picked 20 different times, in a random manner.</p><p>Example: The order of the points appearing could be:</p><p>7,31,25,43,7,42,15,...... (each number represents the corresponding X and Y values of the concerned point)</p><p>As I have shown, the same point might appear close to itself without all the other points being picked out. I cannot seem to think of an efficient construct to implement what I need. The best I can think of is to pick all the 50 points in some order and then once all the 50 points have been picked, start over again and pick them. But this doesn't completely meet my requirements, as I would like the points to appear close to each other occasionally too (based on MATLAB's random ordering).</p>Hakeem Mogambohttps://se.mathworks.com/matlabcentral/profile/authors/9187659-hakeem-mogambotag:se.mathworks.com,2005:Question/3419822017-05-25T21:59:16Z2017-05-30T02:23:17ZHDL coder simulation for video processing takes very long time. Is there way to do it faster ?<p>I have discrete-time settings with fixed step of 1.
The frame size of video input 480 x 640.</p>Mohammed Shameem Hussainhttps://se.mathworks.com/matlabcentral/profile/authors/6718813-mohammed-shameem-hussaintag:se.mathworks.com,2005:Question/3424462017-05-30T02:17:49Z2017-05-30T02:22:19ZCorrect codes but no graph shows<p>What do you do when your codes are correct but the graph does not show
And do you add other graphs to be on same graph</p>Samuel Suakyehttps://se.mathworks.com/matlabcentral/profile/authors/10402734-samuel-suakyetag:se.mathworks.com,2005:Question/3424442017-05-30T01:41:38Z2017-05-30T02:16:51ZExplanation of the code sequence <p>Given that T=zeros(100,100,10)
and I want to understand this sequence T(1,:,9)</p>elvin eziamahttps://se.mathworks.com/matlabcentral/profile/authors/8757704-elvin-eziamatag:se.mathworks.com,2005:Question/3421272017-05-26T20:24:58Z2017-05-30T02:08:42Zspatial FFT of a series of wave signals<p>Hello,
I would like to ask you, if you can help me with the 2D FFT of a series of time signals, which relate to the propagation of symmetric and antisymmetric mode of Lamb wave. In COMSOL multiphysics, I´ve made a simulation of propagation of particular modes of Lamb wave. In the model, there were placed thirty points on which the displacement vs time has been recorded. Now, I would like to make a spatial 2D FFT in order to get the frequency-wavenumber graph.
From COMSOL multiphysics, I´ve exported a matrix, which contains all thirty time signals from these points (arranged in columns). Then, I´ve imported the data into matlab and tried to apply the 2D FFT according to help (unsuccessfully). Is it please possible to give me an advice from where to start? Thank you</p>MShttps://se.mathworks.com/matlabcentral/profile/authors/9342950-mstag:se.mathworks.com,2005:Question/3424152017-05-29T19:01:46Z2017-05-30T02:03:05ZHow to correct for peak shits in an FTIR spectrum<p>Hello:
Say I have two spectra, Spectrum A and Spectrum B. Spectrum A is the reference spectrum and spectrum B is one I just collected. I'm trying to match spectrum B with the reference spectrum A. However, I realized that the peaks in B are a bit shifted.</p><p>My question is how do I correctly align B to the reference A using matlab. Any matlab code or GUI?</p><p>Thank you.</p>Francis Kwofiehttps://se.mathworks.com/matlabcentral/profile/authors/8298095-francis-kwofietag:se.mathworks.com,2005:Question/3424182017-05-29T19:20:44Z2017-05-30T01:57:53Z Hi can anyone please let me know, how can i generate s-parameters for a transfer function in MATLAB..Thanks in advance<p>Hi can anyone please let me know, how can i generate s-parameters for a transfer function in MATLAB..Thanks in advance</p>manjunath Hanumanthaihhttps://se.mathworks.com/matlabcentral/profile/authors/3330434-manjunath-hanumanthaihtag:se.mathworks.com,2005:Question/3359492017-04-18T14:50:35Z2017-05-30T01:57:35ZDatafeed returns an error using fetch function<p>Hi everybody,</p><p>I'm trying to use "fetch" function with this code:</p><pre class="language-matlab">fetch(yahoo,'SPY',today())
</pre><p>but I recive this error:</p><p>Error using yahoo
Unable to connect or retrieve data from given URL.</p><p>I used the same code 3 days ago and it worked. What's going on? Thanks!</p>Adrianohttps://se.mathworks.com/matlabcentral/profile/authors/5461029-adrianotag:se.mathworks.com,2005:Question/3423962017-05-29T16:18:32Z2017-05-30T01:42:18ZRemoving leverage = infinite loop?<p>I have a nonlinear model and I used plotDiagnostics (model, 'leverage') to find observations with high leverage.</p><p>However,after removing those which are extremely high (about 6 points), I noticed that the threshold of the new leverage plot has changed, and there are new points fall beyond this new threshold. If I were to remove all points lying above the threshold (about 20 of them), it is very likely that some points will exceed the new threshold, and eventually will this whole process of removing leverage and re-plotting leverage plot become an endless loop?</p>wesleynotwisehttps://se.mathworks.com/matlabcentral/profile/authors/10338091-wesleynotwisetag:se.mathworks.com,2005:Question/3424412017-05-30T01:23:01Z2017-05-30T01:23:01ZHow I can Modify weights of feedforward neural network in Matlab?<p>Hello</p><p>I am training a neural network with feedforwardnet using 13 neurons at input layer, 7 at hidden and 3 at output layer. The training function is 'trainrp'. I want to modify weights of this network for input-hidden and hidden-output layer with certain value obtained from optimization technique.</p><p>I basically need to check my weights when I get 99% accuracy from simple feedfordward net training and then want to modify these weights with velocity value obtained from PSO so that accuracy can be improved.</p><p>Kindly help me to know how it can be done in MATLAB.</p><p>I am using Matlab 2015.</p>JAGRITI SAINIhttps://se.mathworks.com/matlabcentral/profile/authors/7194759-jagriti-sainitag:se.mathworks.com,2005:Question/3424402017-05-30T01:19:43Z2017-05-30T01:19:43ZNetwork visualization distance between nodes<p>Hi, I am working on a network visualization project for my university. This important point here is to actually show when nodes are far or close to each other. I want the plot to show how far or how close a node is from each other given the weights.
I created a random network just to figure out the commands, as follows:</p><pre class="language-matlab">s = [1 1 1 2 1 2 5];
t = [2 3 5 4 6 7 8];
weights = [1 2 5 20 3 5 1];
names = {'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H'};
G = graph(s,t,weights,names);
plot(G);
</pre><p>When I run this, no matter the numbers I put in the weights array, the image itself when I plot does not change. How can I manage to actually show in the plot that point A for example is closer to point B then from point F.
The illustrative aspect is very very important.</p><p>Thank you!
Felipe.</p>Felipe Schubackhttps://se.mathworks.com/matlabcentral/profile/authors/6564628-felipe-schubacktag:se.mathworks.com,2005:Question/3298432017-03-14T17:11:36Z2017-05-30T01:14:59ZVISA Serial Read - Unsuccessful read: A timeout occurred before the Terminator was reached.<p>I am trying to interact with stepper motor controllers using VISA serial communications. I have NI-DAQmx and NI-VISA support packages installed within MATLAB R2016a. Serial writes seem to function perfectly; however, serial reads issue a timeout warning (“Warning: Unsuccessful read: A timeout occurred before the Terminator was reached.”) and always take at least 1 second. Surprisingly, the serial read always retrieves the expected data. I have already have tried shortening (down to 1 ms) and lengthening (up to 10 s) the timeout, implementing a pause before reading the serial data (to give the controller time to process my request and put data onto the serial bus), and tried changing the read terminators to every possible ASCII character. The last characters in every data read are always (ASCII): EXT, CR and LF. Bottom line is that serial read kind of works, but always has a timeout warning and takes too long (at least 1 second).
My code is attached. Any help or advice would be much appreciated!</p><pre class="language-matlab">% Serial settings
vs = visa('ni', 'ASRL3::INSTR'); % Create VISA serial object
vs.BaudRate = 9600; % Rate of transmission [bit/s]
vs.DataBits = 8; % Number of data bits
vs.Parity = 'none'; % No parity
vs.FlowControl = 'none'; % No flow control
vs.StopBits = 1; % Number of stop bits
vs.Terminator = {'LF', 'CR'}; % Read and write terminator
set(vs, 'Timeout', 0.05); % Set timeout [s]
</pre><pre class="language-matlab">query_cmds = '/1?8R'; % String to request encoder position
</pre><pre class="language-matlab">% Send serial commands to controllers
fopen(vs); % Open serial port
pause(.010) % Time delay [s]
</pre><pre class="language-matlab">disp('Query Commands Sent to Controllers')
disp(query_cmds)
fprintf(vs, query_cmds); % Ask controllers for encoder position
tic
query_resp = fscanf(vs);
toc
</pre><pre class="language-matlab">fclose(vs); % Close serial port
</pre>Peteyhttps://se.mathworks.com/matlabcentral/profile/authors/3736935-peteytag:se.mathworks.com,2005:Question/2715642016-03-05T03:28:48Z2017-05-30T01:05:05ZHow do I change font size for Live Scripts?<p>The option to change the font size for the new "Live Scripts" is not in preferences where you can change all the other font sizes. On my installation, the Live Script font size is about 8, way too small. Thanks for the help.</p>Philiphttps://se.mathworks.com/matlabcentral/profile/authors/1089873-philiptag:se.mathworks.com,2005:Question/3423492017-05-29T09:47:27Z2017-05-30T00:01:43ZSawtooth wave, using complex fourier transform find first 7 harmonic<p>There is a sawtooth wave with period T=1s and equation x(t)=t in the interval 0<=t<=T . Using the complex form of fourier transform , define the real amplitudes of the first 7 harmonic, without finding the phases. Could anyone help me do this in matlab ?</p><img src = "/matlabcentral/answers/uploaded_files/79041/help.bmp">Stanislav Kotzevhttps://se.mathworks.com/matlabcentral/profile/authors/10399365-stanislav-kotzevtag:se.mathworks.com,2005:Question/3423082017-05-29T02:07:38Z2017-05-29T23:59:21ZI have used two different methods for same problem and getting different plots<pre> %----------------CODE - 1-----------------------------
function second_order_ode
clc
clear
t = 0:0.001:3; % time scale
initial_x = 0;
initial_dxdt = 0;</pre><pre> [t,x] = ode45 ( @rhs, t, [initial_x, initial_dxdt]);
plot(t,x(:,2));
xlabel('t'); ylabel('x');
title('Solution to ODE d^2x/dt^2+5dx/dt-4x(t)=sin(10t)')
disp([t,x(:,2)])</pre><pre> function dxdt=rhs(t,x)
dxdt_1 = x(2);
dxdt_2 = -5*x(2)+4*x(1)+sin(10*t);
dxdt = [dxdt_1; dxdt_2];
end
end
%----------------CODE - 2-----------------------------
clc
clear
syms x t
x = Dsolve('D2x + 5*Dx - 4*x = sin(10*t)','x(0)=0','Dx(0)=0','t')
tt = 0:.01:3
xx = subs(x,t,tt)
plot(tt,xx)</pre>Taha Abbas Bin Rashidhttps://se.mathworks.com/matlabcentral/profile/authors/7949631-taha-abbas-bin-rashidtag:se.mathworks.com,2005:Question/3424082017-05-29T17:26:30Z2017-05-29T23:54:13ZUpgrade Matlab to 2017<p>I have Matlab 2016a installed in my laptop. But I need some functions in Matlab 2017a.
Do I need to buy Matlab 2017 in order to use the functions??</p>Sugyani Mahapatrahttps://se.mathworks.com/matlabcentral/profile/authors/9347535-sugyani-mahapatratag:se.mathworks.com,2005:Question/3424382017-05-29T23:22:40Z2017-05-29T23:46:18ZHow to detect objects using fourier<p>I have a image with many objects, then I need to find an specific object among the others.
But I need use Fourier for solve this problem.
We already find some solutions gave by Image Analyst but only find edges and not the whole objects cordinates (specif object).
Example: I have a table with office objects and we need to find the pen cordinates, using Fourier.</p>RAPHAEL RIBEIRO DE GOUVEIAhttps://se.mathworks.com/matlabcentral/profile/authors/4468645-raphael-ribeiro-de-gouveiatag:se.mathworks.com,2005:Question/3410082017-05-19T14:41:46Z2017-05-29T23:20:25Z Write a function called approximate_e that uses the following formula to compute e, Euler’s number: = 1 ! ∞ = 1+1+ 1 2 + 1 6 + 1 24 +⋯ Instead of going to infinity, the function stops at the smallest k for which the approximation differs from<pre class="language-matlab">function [est, n ] = approximate_e( delta )
%APPROXIMATE_E Summary of this function goes here
% Detailed explanation goes here
n =1;
est = 0;
while abs(exp(1)> delta
if n ==1
est = 1;
end
if n == 2
est = 2;
end
if n >2
est = est+1/prod(1:(n-1));
end
n = n + 1;
if n >10000
</pre><pre> break;
end
end</pre><p>could you please tell me how one can solve above mention question.
thanks</p>Wasi von Deutschlandhttps://se.mathworks.com/matlabcentral/profile/authors/10267023-wasi-von-deutschlandtag:se.mathworks.com,2005:Question/2806982016-04-24T12:44:44Z2017-05-29T23:11:16ZCheck error rate from Principal Component Analysis<p>Hello, For the Matlab code given to find the <a href = "http://www.mathworks.com/matlabcentral/fileexchange/45750-face-recognition-using-pca">Principal Component Analysis found here</a>, how do you go about extracting the error rate of the recognition system with the test data? Here is the code that is posted on the Matlab Exchange website:</p><pre class="language-matlab">%%% face recognition by Kalyan Sourav Dash %%%
clear all
close all
clc
</pre><pre class="language-matlab">datapath = uigetdir('C:\Documents and Settings\KsDash\My Documents\MATLAB','Select path of TRAINING IMAGES');
testpath = uigetdir('C:\Documents and Settings\KsDash\My Documents\MATLAB','select path of TEST IMAGES');
</pre><pre class="language-matlab">prompt = {'Enter test image name (a number between 1 to 60):'};
dlg_title = 'Input of PCA-Based Face Recognition System';
num_lines= 1;
def = {' '};
TestImage = inputdlg(prompt,dlg_title,num_lines,def);
TestImage = strcat(testpath,'\',char(TestImage),'.jpg');
</pre><pre class="language-matlab">D = dir(datapath);
imgcount = 0;
for i=1 : size(D,1)
if not(strcmp(D(i).name,'.')|strcmp(D(i).name,'..')|strcmp(D(i).name,'Thumbs.db'))
imgcount = imgcount + 1; % Number of all images in the training database
end
end
</pre><pre class="language-matlab">X = [];
for i = 1 : imgcount
str = strcat(datapath,'\',int2str(i),'.jpg');
img = imread(str);
[r c] = size(img);
temp = reshape(img',r*c,1);
X = [X temp];
end
</pre><pre class="language-matlab">m = mean(X,2); % Computing the average face image m = (1/P)*sum(Xj's) (j = 1 : P)
imgcount = size(X,2);
</pre><pre class="language-matlab">A = [];
for i=1 : imgcount
temp = double(X(:,i)) - m;
A = [A temp];
end
</pre><pre class="language-matlab">L= A' * A;
[V,D]=eig(L); %% V : eigenvector matrix D : eigenvalue matrix
</pre><pre class="language-matlab">L_eig_vec = [];
for i = 1 : size(V,2)
if( D(i,i) > 1 )
L_eig_vec = [L_eig_vec V(:,i)];
end
end
</pre><pre class="language-matlab">eigenfaces = A * L_eig_vec;
</pre><pre class="language-matlab">projectimg = [ ]; % projected image vector matrix
for i = 1 : size(A,2)
temp = eigenfaces' * A(:,i);
projectimg = [projectimg temp];
end
</pre><pre class="language-matlab">test_image = imread(TestImage);
test_image = test_image(:,:,1);
[r c] = size(test_image);
temp = reshape(test_image',r*c,1); % creating (MxN)x1 image vector from the 2D image
temp = double(temp)-m; % mean subtracted vector
projtestimg = eigenfaces'*temp; % projection of test image onto the facespace
</pre><pre class="language-matlab">euclide_dist = [ ];
for i=1 : size(eigenfaces,2)
temp = (norm(projtestimg-projectimg(:,i)))^2;
euclide_dist = [euclide_dist temp];
end
[euclide_dist_min recognized_index] = min(euclide_dist);
recognized_img = strcat(int2str(recognized_index),'.jpg');
</pre><pre class="language-matlab">%recog_img = facerecog(datapath,TestImage);
selected_img = strcat(datapath,'\',recognized_img);
select_img = imread(selected_img);
imshow(select_img);
title('Recognized Image');
test_img = imread(TestImage);
figure,imshow(test_img);
title('Test Image');
</pre><pre class="language-matlab">result = strcat('the recognized image is : ',recognized_img);
disp(result);
</pre>monkey_matlabhttps://se.mathworks.com/matlabcentral/profile/authors/1029105-monkey_matlabtag:se.mathworks.com,2005:Question/3424202017-05-29T19:28:31Z2017-05-29T23:07:05ZHow can I generated a matrix that I can export to excel for a series of nested for loops?<p>When I export my current method to excel, the nested matrices are not being shown. The following is my current code:</p><pre class="language-matlab">clear all;
clc;
</pre><pre class="language-matlab">%The following is series of nested for loops that defines the essential parameters
%needed to generate the gear profiles of a rack & pinion and worm & worm
%gear that are related to one another by the center to center distance of
%the two gear systems.
</pre><pre class="language-matlab">%the amount of revolutions the pinion rotates is equal to the amount
%rotations the worm will also rotate.
</pre><pre class="language-matlab">for a=5:-1:1 %a (mm) is the center to center distance of the two gear systems, it starts large and shrink by 1mm during each iteration.
for i=1:a % this is sub macro for loop that generates all possible values of the pitch diameters of worm gear and worm for the given center to center distance. i at any given moment is the pitch radius of the worm gear.
if i==1
Pdwg=0; %Pdwg(mm) is the pitch diameter of the worm gear which is essentially a spur gear.
Pdw=2*a; %Pdw(mm) is the pitch diameter of the worm, which is essentially a screw.
else
Pdwg=2*i;
Pdw=2*a-Pdwg;
end
for n=1:4 %this is a micro for loop, when n is the number of threads on the worm.
for j=1:32 %the micro sub loop calculates a series of parameters for series of common pitch angles 14-45 degrees, on the worm.
y=13+j; %y(degrees), the pitch angle on the worm at any given iteration.
revs=((pi*Pdwg/4)/(pi*Pdw*tan(y*(pi/180))*n)); %revs is the amount of revs needed to make the two gear system work as intended, it is the other connecting link between the rack & pinion system and worm & worm gear system.
Pdp=11.62/(pi*revs); %Pdp(mm)is the calculated pitch diameter of the pinion given the set distance the rack will travel 11.62mm and the revs the worm will be making.
H=a-(Pdp/2); %H(mm) is the width of the rack, constrained by the center to system distance of the gear system and well as the pitch diameter of pinion it works in conjunction with.
q(j,:)=table(y,revs,Pdp,H);% this line captures the pitch angle, revs, pinion pitch diameter, and rack height in a table during each iteration of j.
end
r(n,:)=table(n,{q});% this link captures q table generated for each iteration of n, the number of threads on the worm.
end
s(i,:)=table(Pdwg,Pdw,{r});% every value of Pdwg and Pdw as a corresponding r table, this line captures that table with the associated Pdwg and Pdw.
end
t(a,:)=table(a,{s});% at each a iteration there is an associated s table, this line captures that information.
end
</pre><p>I'm trying to get the code to a point where, when I execute one of the excel export commands in the command window. I can open the generated excel file and it will have all the data held in the t variable shown. Is there way I can go about this to get it to work?</p>Alex Simmonshttps://se.mathworks.com/matlabcentral/profile/authors/4191456-alex-simmonstag:se.mathworks.com,2005:Question/3424332017-05-29T21:46:30Z2017-05-29T23:03:35ZHow to stop a while loop, using alphabets. <p>One of my questions, asks to allow the user to input the marks. Any mark less than 40 is a fail. Inbetween 40 and 70 is a pass and anything grater than 70 is classed as excellent. But the question wants for the while loop to end once the user enters 'q' or 'Q'. Here is what I have written down, but I dont really know how to include the condition for 'q' and 'Q'(an error is shown when q or Q is entered).</p><pre class="language-matlab">m=input('please enter the mark:');
while m>=0 && m~=strcmpi('q','Q')
if m>=0 && m<40
disp('fail')
elseif m>=40 && m<70
disp('pass')
else m>=70
disp('excellent')
end
m=input('please enter the mark:');
end
</pre><p>Error shown:</p><pre class="language-matlab">Error using input
Undefined function or variable 'q'.
</pre><pre class="language-matlab">Error in Q2c_15_16_resit (line 10)
m=input('please enter the mark:');
</pre><p>Would really appreciate, if anyone can share a solution for this.</p><p>Thank you.</p>Aswin Kartik Malladihttps://se.mathworks.com/matlabcentral/profile/authors/9582177-aswin-kartik-malladitag:se.mathworks.com,2005:Question/3391072017-05-07T05:54:02Z2017-05-29T23:00:21ZMatlab + Hadoop Integration ??<p>We Followed standard doc for integrating Hadoop-2.7.2 with Matlab-R2016b.
* <b>Link for document*</b> : <a href = "http://in.mathworks.com/help/mdce/configure-a-hadoop-cluster.html">http://in.mathworks.com/help/mdce/configure-a-hadoop-cluster.html</a></p><p>We Completed up to this stage but we are confuse with the rest part....</p><p>The requirements are:</p><ol><li>MATLAB® Distributed Computing Server™ must be installed or available on the cluster nodes. See Install Products and Choose Cluster Configuration.</li><li>If the cluster is running in Kerberos authentication that requires the Java Cryptography Extension, you must download and install the Oracle version of this extension to each MATLAB Distributed Computing Server installation. You must also perform this step for the MATLAB client installation. To install the extension, place the Java Cryptography Extension jar files into the folder ${MATLABROOT}/sys/jre/${ARCH}/jre/lib/security.</li><li>You must have a Hadoop installation on the MATLAB client machine, that can submit normal (non-MATLAB) jobs to the cluster.</li><li>The cluster must identify its user home directory as a valid location that the nodes can access. You must choose a local filesystem path and typically use a local folder such as /tmp/hduserhome or /home/${USER}. Set yarn.nodemanager.user-home-dir for Hadoop version 2.X.</li><li>There is one Hadoop property that must not be "final." (If properties are "final", they are locked to a fixed predefined value, and jobs cannot alter them.)</li><li>The software needs to append a value to this property so that task processes are able to correctly run MATLAB. This property is passed as part of the job metadata given to Hadoop during job submission.</li></ol><p>This property is mapred.child.env, which controls environment variables for the job's task processes.</p><p>You must provide necessary information to the parallel.cluster.Hadoop object in the MATLAB client session. For example, see Run mapreduce on a Hadoop Cluster (Parallel Computing Toolbox) and Use Tall Arrays on a Spark Enabled Hadoop Cluster (Parallel Computing Toolbox).</p><p>*MAIN QUESTION IS .....</p><p>1. We are not able to see any Cluster Configuration in <b>Home->Parallel->Manage_Cluster_Profile</b> ???</p><p><b>2.what is Role of MJS in this and how to configure it.</b></p><p><b>3.we are not understanding what we have to export and import for rest of the worker (slave )and master node*</b> ??</p><p>Thanks</p>Pulkesh Haranhttps://se.mathworks.com/matlabcentral/profile/authors/9189565-pulkesh-harantag:se.mathworks.com,2005:Question/3424372017-05-29T22:54:43Z2017-05-29T22:54:43Zwhich tool box can read metastock and CSI financial data<p>I saw it somewhere in the machine learning area but can't seem to find it</p>ronald ogrenhttps://se.mathworks.com/matlabcentral/profile/authors/8314207-ronald-ogrentag:se.mathworks.com,2005:Question/3424172017-05-29T19:11:18Z2017-05-29T22:47:58ZHow to count occurrences of a number in a column in relation to an other column occurrence<p>i need to count occurrences of a number in a column in relation to an other column occurrence
so e.g</p><p>A=</p><p>4 2 1</p><p>2 2 1</p><p>1 1 2</p><p>1 1 7</p><p>1 2 1</p><p>i need the number of times column 2 has a 1 while column 3 has a 7 so [any,1,7] and column 1 has a 2 while column 3 has a 7 so [2,any,7]
I've tried</p><p>sum(A(:,2:3)==[1,7])</p><p>but that just gets the number of 1 and the number 7</p><p>(the real mat that i have to do is large)</p>Andrew Sedgleyhttps://se.mathworks.com/matlabcentral/profile/authors/6287140-andrew-sedgleytag:se.mathworks.com,2005:Question/3424252017-05-29T19:58:20Z2017-05-29T22:11:01ZHow can I fix this problem <p>I am trying to get a normalized matrix.</p><pre> A=[1 1 2 4 7 1;0 2 2 1 3 9;
1 2 1 1 1 9;1 3 0 1 4 1];
R=size (A,1); % Row
C=size (A,2); % Column
for i=1:C
N=A(:,i)/sqrt(sum(A(:,i).^2));
S(i,:)=N
end</pre><p>I do not get a right rows, then I tried a transpose and it does not work "nothing change".</p>fshttps://se.mathworks.com/matlabcentral/profile/authors/9234163-fstag:se.mathworks.com,2005:Question/3424242017-05-29T19:56:19Z2017-05-29T22:10:44Zconvert spectre to RGB<p>Hello all. I need to convert from spectra to RGB and for this i find roo2rgb function. But this function need 3
RGB=roo2rgb(ROO,RGBTYPE,WL)
parameters, and i have only wavelength and reflection coefficient. Anybody know how i can solve my task?</p>Andriy Bashukhttps://se.mathworks.com/matlabcentral/profile/authors/10401037-andriy-bashuktag:se.mathworks.com,2005:Question/3424342017-05-29T21:52:51Z2017-05-29T21:52:51Znot enough input arguments in undistortImage in batch processing app<p>error arising when using undistortImage inside a batch processing app</p>daniele troilohttps://se.mathworks.com/matlabcentral/profile/authors/10225127-daniele-troilotag:se.mathworks.com,2005:Question/3423652017-05-29T12:49:37Z2017-05-29T21:49:45ZInputname statement - useful example<p>Hi everyone,</p><p>could you help me to understand what is the useful of the inputname statement? I run the following example:</p><pre class="language-matlab">function c = somma(a, b)
disp(inputname(1))
c = a + b;
</pre><p>in workspace:</p><pre class="language-matlab">x = 1;
y = 2;
somma(x, y) %x is the result
</pre><p>From my example is not clear the useful of inputname. If you have a best example, let me know please.</p><p>Thank you.</p>Gennaro Arguzzihttps://se.mathworks.com/matlabcentral/profile/authors/5269044-gennaro-arguzzitag:se.mathworks.com,2005:Question/521502012-10-29T07:09:40Z2017-05-29T21:46:38Zconfusion in VL_SLIC , outpur varies depending on how image is read<p>Hi, I am using VL_SLIC to implement segmentation. However the outputs vary depending on how I read the image.</p><p>Way1: Read the img as im2double , so the intensity ranges from 0 to 1. Here, the output superpixels are more regular and spacious.</p><pre class="language-matlab">%Input
img = im2double(imread('Images/2_14_s.bmp'));
regionSize = 30 ;
regularizer = 0.1;
</pre><pre class="language-matlab">%get the SLIC superpixels
vl_setup
segments1 = vl_slic(single(img), regionSize, regularizer) ;
</pre><p>Way2: Read the img as uint8 , so the intensity ranges from 0 to 255.
Here, the output superpixels are more irregular but tightly fit to the edges.</p><pre class="language-matlab">%Input
img = imread('Images/2_14_s.bmp');
regionSize = 30 ;
regularizer = 0.1;
</pre><pre class="language-matlab">%get the SLIC superpixels
vl_setup
segments1 = vl_slic(single(img), regionSize, regularizer) ;
</pre><p>here are the images:</p><p><a href = "http://swagatikapanda-vision.blogspot.in/2012/10/confusion-in-vlslic.html">http://swagatikapanda-vision.blogspot.in/2012/10/confusion-in-vlslic.html</a></p><p>I want to know which is the right way? and why this change is affecting the performance?</p>Swagatikahttps://se.mathworks.com/matlabcentral/profile/authors/3346057-swagatikatag:se.mathworks.com,2005:Question/3423122017-05-29T03:10:13Z2017-05-29T21:36:49Zhow do i correct this error in command bvp4c?<p>the optimal control i used the command BVP4C but i don't use because generates me a this error</p><p>my code is:</p><pre class="language-matlab">function dydx = ex1ode(x,y)
</pre><pre> dydx = [y(2)
-2.2727*y(1)+ (-1.1364)*y(2)+(0.0136)*y(3)
(-11)*y(2)+(-40)*y(3)+(1000)*((-1000*y(6))/2*1)
(-2.2727)*y(5),y(4)+((-1.1364)*y(5))+(-11*y(6))
(-1.1364*y(5))+(-40*y(6))];</pre><p>the other function is</p><pre class="language-matlab">function res = ex1bc(ya,yb)
res = [ ya(1); yb(1)-1
</pre><pre> ya(2); yb(2)-10</pre><pre> ya(3); yb(3)-1 </pre><pre> ya(4); yb(4)-1</pre><pre> ya(5); yb(5)-1</pre><pre> ya(6); yb(6)-1];</pre><p>and the principal program is,</p><pre class="language-matlab">clear all
</pre><pre class="language-matlab">clc
</pre><pre class="language-matlab">solinit = bvpinit(linspace(0,18,6),[0 0 0 0 0 1])
</pre><pre class="language-matlab">sol = bvp4c(@ex1ode,@ex1bc,solinit);
</pre><pre class="language-matlab">x = linspace(0,4);
</pre><pre class="language-matlab">y = deval(sol,x);
</pre><pre class="language-matlab">plot(x,y(1,:))
</pre><p>I don't know which the problem</p><pre class="language-matlab">Error using vertcat
Dimensions of matrices being concatenated are not consistent.
Error in ex1ode (line 3)
dydx = [y(2)
</pre><pre class="language-matlab">Error in bvparguments (line 105)
testODE = ode(x1,y1,odeExtras{:});
</pre><pre class="language-matlab">Error in bvp4c (line 130)
bvparguments(solver_name,ode,bc,solinit,options,varargin);
</pre><p>thanks.</p>Stefany Rodriguez https://se.mathworks.com/matlabcentral/profile/authors/7903703-stefany-rodrigueztag:se.mathworks.com,2005:Question/3424322017-05-29T21:22:55Z2017-05-29T21:22:55ZI have got data from accelerometer,gyroscope and magnetometer .It also give me Euler angle data in X,Y,Z coordinates in degree.<p>this is the data from hand movement where I am holding a weight in my hand and moving it up and down.I have to find out out of these given data which data is useful,I need to calculate the kinematics of joint angles,range of motion and transform the data from local coordinates to cartesian coordinates.I also need to find out position vector of centre of mass and weight.</p>Prateek Srivastavahttps://se.mathworks.com/matlabcentral/profile/authors/10070950-prateek-srivastavatag:se.mathworks.com,2005:Question/3424312017-05-29T21:17:39Z2017-05-29T21:17:39ZHow to dynamically change waypoints and make the purepursuit algorithm follow the path in real time?<p>I am using purepursuit for path following. I have an offline genetic algorithm planner which starts off the robot on a path. When there is a dynamic obstacle around, I have designed a loop wherein each iteration gives a new position for the robot using artificial potential field.
I am adding these 'new positions' as new waypoints in already composed list earlier. (They are ordered correctly as well.) But the robot just follows the original waypoints that were determined by GA. In the list of waypoints, I can see the new co-ordinates with each iteration, but the robot doesn't follow all those points, just the original GA points. Can anyone tell me why? Or help me a way around?
NOTE: I have to release controller each time I update the waypoints, could it be that when I 'release', the controller isn't 'set' back again and doesn't care about the new updated list of waypoints to travel?</p>Nisarg Patelhttps://se.mathworks.com/matlabcentral/profile/authors/7135149-nisarg-pateltag:se.mathworks.com,2005:Question/3423672017-05-29T12:59:30Z2017-05-29T21:17:22ZMARIE(Magnetic Resonance Integral Equation Suite) error...<p><b>uiresume (line 26)</b></p><p>*MARIE_COILLoad>COIL_LoadModel_Button_Callback (line 111)</p><p>uiresume(gcbf);*</p><p>*gui_mainfcn (line 95)</p><p>feval(varargin{:});*</p><p>*MARIE_COILLoad (line 42)</p><p>gui_mainfcn(gui_State, varargin{:});*</p><p>*matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)MARIE_COILLoad('COIL_LoadModel_Button_Callback',hObject,eventdata,guidata(hObject))'*</p><p>*uiwait (line 81)</p><p>DestroyedObject Callback (error)*</p>Jae Youn Keumhttps://se.mathworks.com/matlabcentral/profile/authors/10311621-jae-youn-keumtag:se.mathworks.com,2005:Question/3424302017-05-29T21:17:15Z2017-05-29T21:17:15ZWhy it always return the 'time is out ' when i run 'supportPackageInstaller' ?<p>supportPackageInstaller</p>Yu Zhiyuanhttps://se.mathworks.com/matlabcentral/profile/authors/2690662-yu-zhiyuantag:se.mathworks.com,2005:Question/3424232017-05-29T19:53:56Z2017-05-29T21:04:19Zcopy a part of image to a dummy image on specific pixel location?<p>hay i have extracted a blob from an image and its pixelList using regionprops. now i want to copy this blob on a dummy image( equal to original image size) on pixel location of PixelList.is there an easy way to do this?</p>talli sattihttps://se.mathworks.com/matlabcentral/profile/authors/10391957-talli-sattitag:se.mathworks.com,2005:Question/3424262017-05-29T19:59:29Z2017-05-29T20:57:25ZCreate an ROI based on matrix values<p>Hi all,</p><p>Trying to figure out how to auto-create an ROI (region or interest) based on values in a matrix.
For that matter, the matrix has binary values, 0 or 1.
If the cell has '1', than I it's inside an ROI, '0' is out.
So as a result, I would have for that matrix - ROI's that bound the areas where '1' is the value.</p><p>Thanks,
Dor</p>Dor Simonhttps://se.mathworks.com/matlabcentral/profile/authors/7420471-dor-simontag:se.mathworks.com,2005:Question/3424112017-05-29T18:10:20Z2017-05-29T20:47:16Ztraveling salesman problem where the salesman has to reload packages at one of the reload stations due to range and carrying capacity<p>Hello Matlab community,</p><p>I have to design an algorithm that finds the shortest route for an UAV that has to deliver packages to customers. The UAV is able to carry multiple packages but has a weight and an range constraint. There is a truck with batteries and packages in the back and the UAV can swap battery an get new packages at a truckstop. Only the UAV is allowed to deliver packages, not the truck. Does anyone have an algorithm that looks slightly like this, or is able to help me to alter an generic algorithm for example.</p><p>Thanks!</p>Lisa de Boerhttps://se.mathworks.com/matlabcentral/profile/authors/10401444-lisa-de-boertag:se.mathworks.com,2005:Question/3424282017-05-29T20:19:37Z2017-05-29T20:43:26Zbinomial odd mode polynomial coefficients<p>is there a way to get these coefficients of the binomial polynomial, like shown in the photo bellow?</p><p>Thanks</p><img src = "/matlabcentral/answers/uploaded_files/79073/Capture.JPG">fima vhttps://se.mathworks.com/matlabcentral/profile/authors/8659326-fima-vtag:se.mathworks.com,2005:Question/3424272017-05-29T20:07:06Z2017-05-29T20:39:43ZMake black and white pixel image of a grid<p>I have this function which generates a 12x12 maze with lines as borders of the maze. I need to convert it into a monochromatic image of 25x25 with each black pixel being boundary and each white pixel being the available path.</p><p>As maze is generated randomly, I need to update the monochromatic image maze with the original maze.</p><p>Actual maze (randomly generated from code) is attached.</p><img src = "/matlabcentral/answers/uploaded_files/79072/maze.png"><p>Kindly help me out in this regard.</p><pre class="language-matlab">function show_maze(row, col, rr, cc, ptr_left, ptr_up, ptr_right, ptr_down,h)
</pre><pre class="language-matlab">figure(h)
</pre><pre class="language-matlab">line([.5,col+.5],[.5,.5]) % draw top border
</pre><pre class="language-matlab">line([.5,col+.5],[row+.5,row+.5]) % draw bottom border
</pre><pre class="language-matlab">line([.5,.5],[1.5,row+.5]) % draw left border
</pre><pre class="language-matlab">line([col+.5,col+.5],[.5,row-.5]) % draw right border
</pre><pre class="language-matlab">for ii=1:length(ptr_right)
</pre><pre> if ptr_right(ii)>0 % right passage blocked</pre><pre> line([cc(ii)+.5,cc(ii)+.5],[rr(ii)-.5,rr(ii)+.5]);</pre><pre> hold on</pre><pre> end</pre><pre> if ptr_down(ii)>0 % down passage blocked</pre><pre> line([cc(ii)-.5,cc(ii)+.5],[rr(ii)+.5,rr(ii)+.5]);</pre><pre> hold on</pre><pre> end</pre><pre class="language-matlab">end
</pre><pre class="language-matlab">axis equal
</pre><pre class="language-matlab">axis([.5,col+.5,.5,row+.5])
</pre><pre class="language-matlab">axis off
</pre><pre class="language-matlab">set(gca,'YDir','reverse')
</pre><pre class="language-matlab">return
</pre>Mohsina Zafarhttps://se.mathworks.com/matlabcentral/profile/authors/10259611-mohsina-zafartag:se.mathworks.com,2005:Question/3424002017-05-29T16:39:31Z2017-05-29T20:38:17ZImport only certain columns (with numeric values) from multiple text files with complex name<p>Hi everyone!</p><p>I am wishing to import only certain columns (with numeric values) from several text files (approximately 118), into matlab space.</p><p>The name of text files has date estructure (year/month_rest of name) like this:</p><pre class="language-matlab">200705_nam12_Yucatan.bin_output.txt;
200706_nam12_Yucatan.bin_output.txt;
200707_nam12_Yucatan.bin_output.txt;
200708_nam12_Yucatan.bin_output.txt;
200709_nam12_Yucatan.bin_output.txt;
200710_nam12_Yucatan.bin_output.txt;
200711_nam12_Yucatan.bin_output.txt;
200712_nam12_Yucatan.bin_output.txt... until
201705_nam12_Yucatan.bin_output.txt.
</pre><p>As it could be inferred, text files are monthly files from 2007 to 2017, which contain meteorological measurements every three hours.</p><p>I have been working in this routine:</p><pre class="language-matlab">%ROUTINE TO EXTRACT NAM12 TXT TIME SERIES
</pre><pre class="language-matlab">%RANGE YEARS TO IMPORT
YEAR1=2007;
YEAR2=2017;
</pre><pre class="language-matlab">%RANGE MONTHS TO IMPORT
MONTH1=1;
MONTH2=12;
</pre><pre class="language-matlab">name=['nam12_Yucatan.bin_output'];
datafiles = dir('*.txt');
</pre><pre class="language-matlab">ext=['.txt'];
</pre><pre class="language-matlab">cols=[1:5,12:13];
</pre><pre class="language-matlab">DATA=[];
</pre><pre class="language-matlab">for i=1:length(datafiles)
for j=YEAR1:YEAR2
for k=MONTH1:MONTH2
Fname=[num2str(j),num2str(k),'_',name,ext];
A=dlmread(Fname);
DATA=[DATA ; (A(:,cols))];
end
end
end
</pre><pre class="language-matlab">clear A Fname MONTH1 MONTH2 YEAR1 YEAR2 cols datafiles ext i j k name
</pre><p>The problems that I have with this routine are the next:</p><p><b>1.- Name of files.</b> In files which corresponds months from january to september (1-9), I can import text files with this estructure "20075_nam12_Yucatan.bin_output.txt", instead of this: "200705_nam12_Yucatan.bin_output.txt". Unfortunately, for those months, the software which generated the text files, add a "0" at the left of the month field. Due to the amount of files, I find unpractical to edit manually the names of text files, and I am wishing that the script can import such a files.</p><p>2.- <b>Incomplete years</b>. In some years, there are not all twelve months available (for example, in 2007 I have from may to december, in 2011 there is not october, etc.). When I execute the script, this "stops" when it doesn't find one monthly file.</p><p><b>3.- Amount of data imported.</b> I am only wishing to import the columns of interest, however, with the loop that I have developed until this moment, it imports to the matlab space firstly the whole data (line: A=dlmread(Fname);) and secondly the columns of interest (line: DATA=[DATA ; (A(:,cols))];). I have find that this kind of condition increase the time of computation.</p><p>Wew! It seems to be a lot of doubts, but I really will appreciate your help.</p><p>I am attaching to this message some examples of the files that I am trying to import into matlab space.</p><p>Best,</p><p>Miguel</p>Miguel Lhttps://se.mathworks.com/matlabcentral/profile/authors/6796184-miguel-ltag:se.mathworks.com,2005:Question/3422922017-05-28T22:40:07Z2017-05-29T20:36:15ZHow to show a video frame by frame in axes<p>Hello!
I am trying to show a video frame by frame into an axes object using guide.</p><p>I have a variable named nFrames that has every frame of the video, so i want to use a for cycle using that variable to put every frame of the video and show it on axes, any help would be amazing.
I tried using the following code but it does not show anything in the object</p><pre class="language-matlab">n = 1:1:nFrames
pause(1);
axes(handles_part2.fig);
imshow(vid,x);
</pre><p>vid is the variable that has the video stored in it</p>Luis Duranhttps://se.mathworks.com/matlabcentral/profile/authors/10394333-luis-duran