Vectors must be the same length.

9 ビュー (過去 30 日間)
Mohammad Asadul Islam sazid
Mohammad Asadul Islam sazid 2021 年 7 月 4 日
編集済み: Sulaymon Eshkabilov 2021 年 7 月 4 日
Every time I run this code, I get "Error using plot Vectors must be the same length.
Showing error in line-8.
reading the audio input signal
[y, Fs] = audioread('recording for lab.wav')
x = resample(y, 8000, 44100);
info = audioinfo('recording for lab.wav')
t = 0:seconds(1/Fs):seconds(info.Duration);
t = t(1:end);
figure()
subplot(1,1,1)
plot(t,y)
xlabel('time')
ylabel('amplitude')
title('audio signal')
  3 件のコメント
Nitin Phadkule
Nitin Phadkule 2021 年 7 月 4 日
size of t and y must be same i.e. number of values in array t and y must be equal
Mathieu NOE
Mathieu NOE 2021 年 7 月 4 日
hello ,
You are not using Fs info to generate the time stamps (uh !) , and even worse you do a resampling function and do not apply the implication on Fs (that then would generate the right t vector)
so no wonder signal and time vector are of different length

サインインしてコメントする。

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 7 月 4 日
編集済み: Sulaymon Eshkabilov 2021 年 7 月 4 日
A small err in t's size:
...
t = t(1:end-1); % 1 last value has to be removed.
...

カテゴリ

Help Center および File ExchangeAudio I/O and Waveform Generation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by