Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Re: Storing the value of a variable
Posted:
Feb 10, 2013 3:30 AM


On 2/9/2013 9:22 PM, Subash Padmanaban wrote: > a=mmreader('abcd.avi'); > for k= 55 : 65 > frame=read(a,k); > level= graythresh(frame); > fig=im2bw(frame,level); > imshow(fig); > numberofpoints=1; > [x y]=ginput(numberofpoints); > plot(x,y); > end > > My problem is that, I want to store the values of x and y in an > array and later plot it. How do I go about with this? Also, every > time the number of frames will not be the same. >
You know the total size of x and y needed? It is the length of each loop * numberofpoints. Hence you can preallocate a matrix to store then in.
 close all; N = 3; numberofpoints = 4; data = zeros(numberofpoints,2,N); %store all points
for i=1:N [data(:,1,i) data(:,2,i)] = ginput(numberofpoints); end
%get the points out and plot them X = permute(data,[1 3 2]); X = reshape(X,[],size(data,2),1) plot(X(:,1),X(:,2),'ro') 
Nasser



