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

์กฐํšŒ ์ˆ˜: 167(์ตœ๊ทผ 30์ผ)
Marwan Malaeb
Marwan Malaeb 2017๋…„ 4์›” 20์ผ
๋Œ“๊ธ€: Joshua Iascau 2022๋…„ 4์›” 13์ผ
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.

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ถ”๊ฐ€ ๋‹ต๋ณ€(2๊ฐœ)

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

ํƒœ๊ทธ

Community Treasure Hunt

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

Start Hunting!

Translated by