How can i plot three periods of a signal

11 ビュー (過去 30 日間)
Deniz Bozdogan
Deniz Bozdogan 2021 年 6 月 12 日
回答済み: Scott MacKenzie 2021 年 6 月 13 日
Hello, i have the following signal and i want to plot three periods of it
t=[0:0.0002:20];
xc1=cos(2*pi*493.88*t);
How can i do it? Thank you for your help

採用された回答

Image Analyst
Image Analyst 2021 年 6 月 12 日
Try it this way:
% t=[0:0.0002:20];
% xc1=cos(2*pi*493.88*t);
% argument in cos = 2*pi*t/period. So
period = 1/493.88
threePeriods = 3 * period
% Make 1000 points over that 3 period.
t = linspace(0, threePeriods, 1000);
% Make xc1 with that t:
xc1 = cos(2 * pi * t / period);
% Plot it
plot(t, xc1, 'b-', 'LineWidth', 2);
xlabel('t', 'FontSize', 15);
ylabel('xcl', 'FontSize', 15);
grid on;
caption = sprintf('Three Periods of cos(2 * pi * t / period), where period = %f', period);
title(caption, 'FontSize', 15);
  1 件のコメント
Deniz Bozdogan
Deniz Bozdogan 2021 年 6 月 12 日
Thank you so much

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

その他の回答 (1 件)

Scott MacKenzie
Scott MacKenzie 2021 年 6 月 13 日
If you want to plot three periods of a signal and do it by extracting the data from your existing code, then
t=[0:0.0002:20];
xc1=cos(2*pi*493.88*t);
idx3 = find(t>=3/493.88,1);
plot(xc1(1:idx3));

カテゴリ

Help Center および File ExchangeGet Started with Signal Processing Toolbox についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by