Saving loop values as column vector

4 次查看(过去 30 天)
Deniz Terzioglu
Deniz Terzioglu 2021-11-30
回答: Voss 2021-11-30
I have a very simple loop that gives out values for d. How would I make it so that these values are saved to a 1 by n matrix?
c=6.25;
x=2.5;
>> for loop = 1:25
d=c-(c^-2+x*c)
c=d;
end

回答(1 个)

Voss
Voss 2021-11-30
d = zeros(1,25);
c = 6.25;
x = 2.5;
for loop = 1:25
d(loop) = c-(c^-2+x*c);
c = d(loop);
end

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by