how to plot m(t)=cos(2*pi*9*t) 0<t<3 and m(t)=0 otherwise

4 ビュー (過去 30 日間)
sameh mostafa
sameh mostafa 2016 年 3 月 15 日
回答済み: Juhi Maraskole 2020 年 8 月 18 日
how to plot m(t)=cos(2*pi*9*t) 0<t<3 and m(t)=0 otherwise

採用された回答

Star Strider
Star Strider 2016 年 3 月 15 日
This works:
m = @(t) cos(2*pi*9*t) .* ((t > 0 ) & (t < 3));
t = linspace(-1, 4, 500);
Out = m(t);
figure(1)
plot(t, Out)
grid
  2 件のコメント
sameh mostafa
sameh mostafa 2016 年 3 月 15 日
i want better resolution
Star Strider
Star Strider 2016 年 3 月 15 日
Change the ‘t’ assignment to:
t = linspace(-1, 4, 5000);
to improve the resolution by a factor of 10. Increase the third argument (here 5000) to get the resolution you want, if this is not enough.

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

その他の回答 (3 件)

Ced
Ced 2016 年 3 月 15 日
編集済み: Ced 2016 年 3 月 15 日
You can use logical vectors to select certain parts of a vector.
t = -1:0.01:4;
m = zeros(length(t),1);
ind_interest = (t > 0 & t < 3); % this creates a logical vector
m(ind_interest) = cos(2*pi*9*t(ind_interest));
plot(t,m);
xlabel('time [s]')
Cheers

sameh mostafa
sameh mostafa 2016 年 3 月 15 日
how to calculate the fourier transform and plot it of m(t)=cos(2*pi*9*t) 0<t<3 and m(t)=0 otherwise

Juhi Maraskole
Juhi Maraskole 2020 年 8 月 18 日
X(t) = 1+ 1/2cos(2πt) + cos(4πt) + 2/3cos(6πt)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by