hello i want to generate y(n)=y(n-1)+x(n). by using a for loop I can find the last value of y, but i need to store all values of y from n =1 till n. Who do I do that?

 Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 20 Apr. 2017

2 Stimmen

n=10
y0=0; % Initial conditions
y(1)=y0+x(1);
for k=2:n
y(k)=y(k-1)+x(k)
end

Weitere Antworten (3)

Roger Stafford
Roger Stafford am 20 Apr. 2017

0 Stimmen

That is precisely what the matlab ‘cumsum’ function does:
y = cumsum(x);
polat kayhan
polat kayhan am 24 Mai 2021

0 Stimmen

𝑋𝑛+1 = 𝑋𝑛 2 + 0.25
Information about its relation, calculate the value of its relation for a value of n, register
Write a computer program whose result will be output for n = 0, 5, 10, 15,… communication only.
n = 0,1,2,3,…., 54
Sanskriti
Sanskriti am 10 Jan. 2025

0 Stimmen

n=10
y0=0; % Initial conditions
y(1)=y0+x(1);
for k=2:n
y(k)=y(k-1)+x(k)
end

1 Kommentar

Walter Roberson
Walter Roberson am 10 Jan. 2025

this is what Azzi posted years ago https://www.mathworks.com/matlabcentral/answers/336375-generate-y-n-y-n-1-x-n#answer_263817

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Parallel Computing Toolbox finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by