Generating triangle wave form

조회 수: 3 (최근 30일)
Horvath
Horvath 2024년 6월 28일
댓글: Horvath 2024년 7월 16일
Hi everyone!
I was wondering how can i generate a triangle wave form? I don't want to use the pre-prepared block with simulink for this purpose (I want to generate code from it which is effective). I know if i integrate a square wave form i can get the triangle wave form but at that case i have to generate a square wave.
Any ideas or help would be nice
Thanks for the answers.

채택된 답변

Aquatris
Aquatris 2024년 6월 28일
편집: Aquatris 2024년 6월 28일
You can use the general equation for the triangle wave and implement it using simple simulink blocks
t = 0:0.01:10; % time
f = @(t,p) 2*abs(t/p-floor(t/p+1/2)); % t is time p is period, this create triangle wave in 0-1 range
plot(t,f(t,1))
plot(t,f(t,10))
  댓글 수: 1
Horvath
Horvath 2024년 7월 16일
Thank you so much for the help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by