Error using plot Vectors must be the same length

I want to correlate the signals x1 and y and plot it for the range n=0:59; but when I run the following code it gives error: Error using plot
Vectors must be the same length.
n=0:59;
x=[1 1 1 1 1 -1 -1 1 1 -1 1 -1 1 ];
x=[x, zeros(1, length(n) - length(x))];
x1=x.^n;
subplot 221
stem(n,x1)
n1=20:79;
x2=0.9*(x1.^n1);
y=imnoise(x2,'gaussian');
subplot 222
stem(n,y)
z=xcorr(x1,y);
subplot 223
stem(n,z)
I have tried solving the problem but had no luck whatsoever. Any help would be appreciated.

Respuestas (1)

Star Strider
Star Strider el 24 de Nov. de 2019
One option is to plot ‘z’ as a function of the lags xcorr computes:
[z,lags] = xcorr(x1,y);
subplot 223
stem(lags,z)

Etiquetas

Preguntada:

el 24 de Nov. de 2019

Respondida:

el 24 de Nov. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by