Hi, I'm new to this site and am trying to teach myself matlab. I came across this problem and can't seem to figure it out;
Write a MATLAB script to derive and plot y(n) below;
x(n) =[1 1 2 1 3] y(n)=x(n)+y(n-1)
I have written the following code;
N = 5;
x = [1 2 2 1 4];
n = 0:length(y)-1;
y(n)=x(n)+y(n-1);
stem(n,y)
...but MATLAB is giving me the following error message;
Subscript indices must either be real positive integers or logicals.
Error in test (line 4)
y(n)=x(n)+y(n-1);
Any help would be greatly appreciated.
Ruairdh
Write a MATLAB script to derive and plot y(n) below;
x(n) =[1 1 2 1 3] y(n)=x(n)+y(n-1)
I have written the following code;
N = 5;
x = [1 2 2 1 4];
n = 0:length(y)-1;
y(n)=x(n)+y(n-1);
stem(n,y)
...but MATLAB is giving me the following error message;
Subscript indices must either be real positive integers or logicals.
Error in test (line 4)
y(n)=x(n)+y(n-1);
Any help would be greatly appreciated.
Ruairdh