How to solve this error Index exceeds the number of array elements. Index must not exceed 198450. Error in quant (line 23) plot(t(zoom),Y2(zoom));

조회 수: 3 (최근 30일)
[Y,Fs] = audioread('signal1.wav');
info = audioinfo('signal1.wav');
t = 0:seconds(1/Fs):seconds(info.Duration);
t = t(1:end);
Y1 = upsample(Y,2);
Y2 = downsample(Y,2);
Y3 = upsample(Y2,2);
Y4 = upsample(Y3,2);
zoom = 200000:200000+length(t)/120;
subplot(6,1,1)
plot(t(zoom),Y(zoom));
title('Original Audio Signal')
ylim([-2 2])
soundsc(Y,Fs)
hold on
subplot(6,1,2)
plot(t(zoom),Y1(zoom));
title('Y1')
ylim([-2 2])
soundsc(Y1,Fs)
hold on
subplot(6,1,3)
plot(t(zoom),Y2(zoom));
title('Y2')
ylim([-2 2])
soundsc(Y2,Fs)
hold on
subplot(6,1,4)
plot(t(zoom),Y3(zoom));
title('Y3')
ylim([-2 2])
soundsc(Y3,Fs)
hold on
subplot(6,1,5)
plot(t(zoom),Y4(zoom));
title('Y4')
ylim([-2 2])
soundsc(Y4,Fs)
hold on
subplot(6,1,6)
plot(t(zoom),Y5(zoom));

답변 (1개)

KSSV
KSSV 2021년 12월 15일
The error is simple amd striaght. You are trying to extract more number of elements than present in the array.
Example:
a = rand(10,1) ; % array has 10 elements
a(1) % no error
a(5) % no error
a(10) % no error
a(11) % error becuase arrays has only 10 elements and you are extracting 11th element
Similarly check the dimensions of Y2.

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by