My for loop execution is not working.
2 次查看(过去 30 天)
显示 更早的评论
I have a time range (t) going from 1 to 20, and a random collection of data of 20 points (y). I need to have y(1,:) for t(1,:), y(2,:) for t(2,:) and so on. This is what I wrote:
for t=1:1:20.0
a = y(1,:) : y(20,:)
end
But all this executes is the just one value of y (the first or the last, I can't tell because they are the same number). What should I correct?
2 个评论
Hiskiel Stephanus
2015-6-9
编辑:Hiskiel Stephanus
2015-6-9
I am assuming you are trying to assign values to an "a" matrix. Try making "a" a dynamic array by saying
a(1,t) = y(1,:) : y(20,:)
采纳的回答
Walter Roberson
2015-6-7
for t = 1:20
a = y(t,:);
fprintf('y value #%t was %g\n', t, a); %example of using the data
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!