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



Nested for loop not working properly
Posted:
Jul 25, 2013 1:15 PM


Here is my code:
span = 450:10:550; yy2 = NaN(size(span)); yy4 = NaN(size(span)); yy6 = NaN(size(span)); yy8 = NaN(size(span)); yy10 = NaN(size(span));
for i = [span]; for j = 1:size(span,2); yy2(j) = F2(i); yy4(j) = F4(i); yy6(j) = F6(i); yy8(j) = F8(i); yy10(j) = F10(i); end end
Essentially, I want to know the value of a each column vector (F2, F4, etc) at a series of particular points (determined by span) and write that value into a slot in an empty matrix. This way, I'll have a single row vector that looks like this:
yy2 = [F2(450), F2(460), etc...] yy4 = [F4(450), F4(460), etc...]
and so on.
But what I get instead is a single row vector filled with the last value determined by span that looks like this:
yy2 = [F2(550), F2(550), etc...]
I have a feeling that this is a very simple fix but I can't figure it out. Any help would be much appreciated!



