Even & Odd Discrete time Signals
I am writing a program to seperate, plot even and odd parts of a discrete time signal. Following is my code:
I am getting error at line 3 & 4. "Array indices must be positive integers or logical values."
Since I am trying to flip and invert the signal x[n] , so ‘x(-n)’ is obvious to use but I am getting error. Kindly help.
n= -3:4;
x=[0 0 0 2 3 -1 2 -3];
xe= ( x(n)+x(-n) )/2;
xo= ( x(n)-x(-n) )/2;
subplot(311);stem(n,x);grid on; xlabel(‘n’);ylabel(‘Amplitude’);title(‘Original Signal’);
subplot(312);stem(n,xe);grid on; xlabel(‘n’);ylabel(‘Amplitude’);title(‘Even Signal’);
subplot(313);stem(n,xo);grid on; xlabel(‘n’);ylabel(‘Amplitude’);title(‘Odd Signal’);I am writing a program to seperate, plot even and odd parts of a discrete time signal. Following is my code:
I am getting error at line 3 & 4. "Array indices must be positive integers or logical values."
Since I am trying to flip and invert the signal x[n] , so ‘x(-n)’ is obvious to use but I am getting error. Kindly help.
n= -3:4;
x=[0 0 0 2 3 -1 2 -3];
xe= ( x(n)+x(-n) )/2;
xo= ( x(n)-x(-n) )/2;
subplot(311);stem(n,x);grid on; xlabel(‘n’);ylabel(‘Amplitude’);title(‘Original Signal’);
subplot(312);stem(n,xe);grid on; xlabel(‘n’);ylabel(‘Amplitude’);title(‘Even Signal’);
subplot(313);stem(n,xo);grid on; xlabel(‘n’);ylabel(‘Amplitude’);title(‘Odd Signal’); I am writing a program to seperate, plot even and odd parts of a discrete time signal. Following is my code:
I am getting error at line 3 & 4. "Array indices must be positive integers or logical values."
Since I am trying to flip and invert the signal x[n] , so ‘x(-n)’ is obvious to use but I am getting error. Kindly help.
n= -3:4;
x=[0 0 0 2 3 -1 2 -3];
xe= ( x(n)+x(-n) )/2;
xo= ( x(n)-x(-n) )/2;
subplot(311);stem(n,x);grid on; xlabel(‘n’);ylabel(‘Amplitude’);title(‘Original Signal’);
subplot(312);stem(n,xe);grid on; xlabel(‘n’);ylabel(‘Amplitude’);title(‘Even Signal’);
subplot(313);stem(n,xo);grid on; xlabel(‘n’);ylabel(‘Amplitude’);title(‘Odd Signal’); dicrete_time_signal MATLAB Answers — New Questions