Error using plot Vectors must be the same length

clc;
clear;
info = audioinfo('cuckoo.wav')
[y,Fs] = audioread('cuckoo.wav');
sound(y,Fs)
info1 = audioinfo('rain.wav')
[y1,Fs1] = audioread('rain.wav')
sound(y1,Fs1)
t=0:seconds(1/Fs):seconds(info.Duration);
t=t(1:end-1);
tt=0:seconds(1/Fs1):seconds(info1.Duration);
tt=tt(1:end-1);
C=conv(y:(1:length(t)),y1(1:length(y1)/10));
subplot(3,1,1);
plot(t,y);
xlabel('Time');
ylabel('Audio Signal');
title('cuckoo');
subplot(3,1,2);
plot(tt,y1);
xlabel('Time');
ylabel('Audio Signal');
title('rain');
subplot(3,1,3);
plot(t,C); %i encounter an error here
the problem is the duration of the 2 file are not the same i think so.
Anyone could help me correct the coding so that i can plot the last graph.

回答(1 个)

Cris LaPierre
Cris LaPierre 2021-1-12
编辑:Cris LaPierre 2021-1-12
Check what the lengths of t and C are. To plot them, they must be the same. The error would suggtest they are not.
Perhaps you want to use conv(u,v,'same'), which returns only the central part of the convolution, the same size as u,

产品

版本

R2019b

标签

Community Treasure Hunt

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

Start Hunting!

Translated by