A very basic question about plotting a signal in the time domain

3 ビュー (過去 30 日間)
Negar
Negar 2013 年 9 月 16 日
Im trying to plot a sound file by the following code, but I get this error each time:_* Vectors must be the same lengths*_. What should I do in order to make it done?
%%Load the signal into MATLAB
[signal,Fs,nbits,opts] = wavread('stry.wav');
%%Plot the signal
tSampling=1/Fs;
t=-0.005:tSampling:0.005;
plot(t,signal);
I plot the signal by this command: plot(signal) but I need the x axis to be the time, and not the samples.
I hope someone can help me!
Negar

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 9 月 16 日
編集済み: Azzi Abdelmalek 2013 年 9 月 16 日
tSampling=1/Fs;
n=numel(signal);
t=-0.005:tSampling:-0.005+(n-1)*tSampling;
plot(t,signal);
%or
t=linspace(-0.005,0.005,numel(signal));
plot(t,signal)
  1 件のコメント
Negar
Negar 2013 年 9 月 17 日
編集済み: Negar 2013 年 9 月 17 日
Thanks a lot ! It was really helpful ! :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by