how to plot this function
古いコメントを表示
how to plot this function x(t) = r(t+2)- r(t+1)- r(t-1)+ r(t-2);
knowing that t = -3:2 ;
help please ??
回答 (1 件)
Atsushi Ueno
2021 年 4 月 14 日
t = -3:2;
plot(t, x(t))
9 件のコメント
Ahmed Amer
2021 年 4 月 14 日
Atsushi Ueno
2021 年 4 月 14 日
You need following as x.m file:
function out = x(t)
out = r(t+2)- r(t+1)- r(t-1)+ r(t-2);
end
and you also need following as r.m file:
function out = r(t)
out = 0; % something your function I don't know
end
Ahmed Amer
2021 年 4 月 14 日
Ahmed Amer
2021 年 4 月 14 日
Atsushi Ueno
2021 年 4 月 14 日
編集済み: Atsushi Ueno
2021 年 4 月 14 日
Thank you. I understand that r() is a ramp function and maybe u() is a step function.
Also, you should check this similar question.
Atsushi Ueno
2021 年 4 月 14 日
You don't need m-file for each function as I said by using anonymous function like other Q&A above.
t = -3:2;
r = @(t) t.*(t>=0);
x = @(t) r(t+2)- r(t+1)- r(t-1)+ r(t-2);
plot(t, x(t));
Ahmed Amer
2021 年 4 月 14 日
Atsushi Ueno
2021 年 4 月 14 日
編集済み: Atsushi Ueno
2021 年 4 月 14 日
I've written the code above. I will repeat it again.
t = -3:2;
r = @(t) t.*(t>=0);
x = @(t) r(t+2)- r(t+1)- r(t-1)+ r(t-2);
plot(t, x(t));
Ahmed Amer
2021 年 4 月 14 日
カテゴリ
ヘルプ センター および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
