Saving loop values as column vector

5 visualizaciones (últimos 30 días)
Deniz Terzioglu
Deniz Terzioglu el 30 de Nov. de 2021
Respondida: Voss el 30 de Nov. de 2021
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

Respuestas (1)

Voss
Voss el 30 de Nov. de 2021
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

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by