Sinus plus straight lines plot

조회 수: 2 (최근 30일)
Arkadius882
Arkadius882 2022년 5월 17일
댓글: Arkadius882 2022년 5월 17일
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일
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
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개)

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by