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일

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,

카테고리

제품

릴리스

R2019b

태그

질문:

2021년 1월 12일

편집:

2021년 1월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by