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!