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
2021년 1월 12일
편집: Cris LaPierre
2021년 1월 12일
0 개 추천
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,
카테고리
도움말 센터 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!