How to write y(n)=y(n-1)+x(n) in a way to store all values of y from n=1 to n?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Marwan Malaeb
am 20 Apr. 2017
Kommentiert: Marwan Malaeb
am 20 Apr. 2017
How to write y(n)=y(n-1)+x(n) in a way to store all values of y from n=1 to n?
0 Kommentare
Akzeptierte Antwort
James Tursa
am 20 Apr. 2017
Bearbeitet: James Tursa
am 20 Apr. 2017
There are vectorized ways to do this, but using your formula directly:
y = zeros(size(x));
y(1) = something; % <-- you fill this in, e.g. maybe x(1)?
n = something; % <-- you fill this in
for k=2:n % <-- for the rest of the elements through n
y(k) = y(k-1) + x(k); % <-- your formula
end
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Coder finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!