generate y(n)=y(n-1)+x(n)

조회 수: 22 (최근 30일)
Marwan Malaeb
Marwan Malaeb 2017년 4월 20일
댓글: Walter Roberson 2025년 1월 10일
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?

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2017년 4월 20일
n=10
y0=0; % Initial conditions
y(1)=y0+x(1);
for k=2:n
y(k)=y(k-1)+x(k)
end
  댓글 수: 1
Marwan Malaeb
Marwan Malaeb 2017년 4월 20일
that is right, thanks Azzi.

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

Roger Stafford
Roger Stafford 2017년 4월 20일
That is precisely what the matlab ‘cumsum’ function does:
y = cumsum(x);
  댓글 수: 1
Joshua Iascau
Joshua Iascau 2022년 4월 13일
you said what?

댓글을 달려면 로그인하십시오.


polat kayhan
polat kayhan 2021년 5월 24일
𝑋𝑛+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 2025년 1월 10일
n=10
y0=0; % Initial conditions
y(1)=y0+x(1);
for k=2:n
y(k)=y(k-1)+x(k)
end
  댓글 수: 1
Walter Roberson
Walter Roberson 2025년 1월 10일

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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by