Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Storing the value of a variable
Replies: 1   Last Post: Feb 10, 2013 3:30 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Nasser Abbasi

Posts: 5,596
Registered: 2/7/05
Re: Storing the value of a variable
Posted: Feb 10, 2013 3:30 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.