How to save for loop values?
1 次查看(过去 30 天)
显示 更早的评论
f=zeros(1,M);
for i=1:M
f(i)=fd+((1+m(i)*r)/2)*f_delta;
f(i)=fd-((1+m(i)*r)/2)*f_delta;
end
I need to save both values for the addition and subtraction.
Thanks in advance.
0 个评论
采纳的回答
Star Strider
2020-2-28
Try this:
f=zeros(2,M);
for i=1:M
f(:,i)=[fd+((1+m(i)*r)/2)*f_delta; fd-((1+m(i)*r)/2)*f_delta];
end
That saves them as different rows of a (2xM) matrix.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!