Matlab

Moderators: None (Apply to moderate this forum)
Number of threads: 1471
Number of posts: 2147

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Collect values to vector Posted by lee_mylo on 6 Apr 2009 at 4:03 AM
Hi to all!

I have written this code. For every a and x I get a value of y.

b=50;
for a = 1:10
for x = 1:255
y = a*x + b
end
end

How can I collect all the values of y to a vector or a matrix?

Thank you in advance
Report
Re: Collect values to vector Posted by giug on 6 Apr 2009 at 6:41 AM
You can do in this way:

b=50;
for a = 1:10
for x = 1:255
y(a,x) = a*x + b
end
end
Report
Re: Collect values to vector Posted by lee_mylo on 6 Apr 2009 at 8:25 AM
thank you so much!



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.