Could anyone create this type of function? It's quarter sinus at the period of [2,-1], [0,1], [2,3] and straight lines at the periods of [-1,0], [1,2], [3,4] with with amplitude of 2.

 採用された回答

Torsten
Torsten 2022 年 5 月 17 日

0 投票

f = @(x) 2*sin((x+2)*pi/2).*(x>=-2).*(x<-1) + (-2*x).*(x>=-1).*(x<=0);
x=-2:0.001:0;
plot(x,f(x))
Can you add the next two cycles ?
Or even better: Construct a periodic function out of it ?

3 件のコメント

Arkadius882
Arkadius882 2022 年 5 月 17 日
Not really, haven't learned that yet :/
Torsten
Torsten 2022 年 5 月 17 日
f = @(x) 2*sin(x*pi/2).*(x>=0).*(x<1) + (-2*(x-2)).*(x>=1).*(x<=2);
g = @(x) f(mod(x,2))
x = -2:0.001:4;
plot(x,g(x))
Arkadius882
Arkadius882 2022 年 5 月 17 日
Many thanks!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

製品

リリース

R2022a

質問済み:

2022 年 5 月 17 日

コメント済み:

2022 年 5 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by