Define time axis interval for 100 samples

I have 2 analog signals which I'd like to sample 100 times.
% sampling frequency (fs) is 6000 Hz
fs1 = 6000;
% I want to take 100 samples of the analog signals
nSamples = 100;
% attempt at axis definition
t1=0:1/fs1:100;
% analog input signals
x1 = (sin(2*pi*1000*t1).^2).*(cos(2*pi*1000*t1).^3);
y1 = (1/8) - (1/8)*cos(1*pi*2000*t1);
How do I define t1 such that I can plot the sampled data

 採用された回答

Star Strider
Star Strider 2022 年 9 月 30 日

0 投票

I am not certain what you want to plot.
Perhaps —
% sampling frequency (fs) is 6000 Hz
fs1 = 6000;
% I want to take 100 samples of the analog signals
nSamples = 100;
% attempt at axis definition
t1=0:1/fs1:100;
% analog input signals
x1 = (sin(2*pi*1000*t1).^2).*(cos(2*pi*1000*t1).^3);
y1 = (1/8) - (1/8)*cos(1*pi*2000*t1);
figure
plot(t1, [x1; y1])
grid
xlabel('t')
ylabel('Amplitude')
legend('x1','y1', 'Location','best')
xlim([0 0.01]) % Optional
I restricted the region of the x-axis to plot here to show detail.
.

4 件のコメント

Huzaifa Ahmad
Huzaifa Ahmad 2022 年 9 月 30 日
Hi, thank you for your response.
I want to plot the frequency response.
Star Strider
Star Strider 2022 年 9 月 30 日
My pleasure!
Do you mean the Fourier transform (fft or pspectrum) or something else?
Huzaifa Ahmad
Huzaifa Ahmad 2022 年 9 月 30 日
Hi I ahve figured it out. I meant the fft.
Thanks again,
Huzaifa
Star Strider
Star Strider 2022 年 9 月 30 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

製品

リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by