Error using plot Vectors must be the same length
Ältere Kommentare anzeigen
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.
Antworten (1)
Star Strider
am 24 Nov. 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)
Kategorien
Mehr zu Correlation and Convolution finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!