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 日間)
muel clamor
muel clamor 2021 年 12 月 15 日
回答済み: KSSV 2021 年 12 月 15 日
[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 Center および File ExchangeSubplots についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by