フィルターのクリア

Why are my vectors different lengths?

2 ビュー (過去 30 日間)
Jesus Marcial
Jesus Marcial 2018 年 10 月 2 日
編集済み: Jan 2018 年 10 月 2 日
load 'gong.mat' %Returns sampling frequency Fs and data y
T=1/Fs; %Sampling period
L=1*y; %Number of samples
t=(0:L)*T; %Time vector.
plot(t,y);
I am trying to plot an audio file (gong crash) and am receiving an error in the final line. The error is "Vectors must be the same length." To my understanding, I am compensating for their length by scaling the time vector by dividing by the sampling frequency "Fs."
Thank you for your time and expertise.
  1 件のコメント
madhan ravi
madhan ravi 2018 年 10 月 2 日
編集済み: madhan ravi 2018 年 10 月 2 日
Upload .mat file

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

回答 (2 件)

Stephen23
Stephen23 2018 年 10 月 2 日
t = T*(1:numel(y));

Jan
Jan 2018 年 10 月 2 日
編集済み: Jan 2018 年 10 月 2 日
L=1*y; %Number of samples
No. 1*y is the same as y. You did not show how y is defined, by I guess that you want:
L = size(y, 1)
% or
L = size(y, 2)
numel(y) works also, if y is a mono signal, but not for stereo. As Stephen has mentioned already, you have to start at the frame 1, not 0: "1:L" instead of "0:L".

カテゴリ

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