Representing samples on analog signal according to the sample period (MATLAB)

1 回表示 (過去 30 日間)
high speed
high speed 2022 年 11 月 30 日
コメント済み: Star Strider 2022 年 11 月 30 日
Dear,
I have this analog signal y from this code:
load handel.mat
filename = 'handel.wav';
audiowrite(filename,y,Fs);
[y,Fe]=audioread('handel.wav');
[N,p]=size(y);
Te=1/Fe;
t=(0:N-1)*Te;
plot(t,y)
Te here is 1.22e-04 in xlabel
The purpose is to represent a sample on the plot according to each value of Te. It means we represent the first sample in Te=1.22e-04 than the second sample in Te=(1.22e-04)*2 ...etc.
How can I do that please!

回答 (1 件)

Star Strider
Star Strider 2022 年 11 月 30 日
The easiest way to create the time vector is:
t = linspace(0, L-1, L)/Fe;
Example —
LD = load('handel.mat');
y = LD.y;
Fe = LD.Fs;
L = size(y,1);
t = linspace(0, L-1, L)/Fe;
figure
plot(t, y)
grid
xlabel('Time (sec)')
ylabel('Amplitude (mV)')
xlim([min(t) max(t)])
Create whatever sort of plot you need to in order to complete your assignment.
.
  2 件のコメント
high speed
high speed 2022 年 11 月 30 日
@Star Strider But this program doesn't represent the samples in the figure !
Star Strider
Star Strider 2022 年 11 月 30 日
Yes, it does!
What do you want to do with that file?
Consider this —
LD = load('handel.mat');
y = LD.y;
Fe = LD.Fs;
L = size(y,1);
t = linspace(0, L-1, L)/Fe;
figure
stairs(t, y)
grid
xlabel('Time (sec)')
ylabel('Amplitude (mV)')
xlim([2.74 2.76])
ylim([-1 1]*0.8)
% xlim([min(t) max(t)])
Create whatever sort of plot you need to in order to complete your assignment.
.

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

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by