Generating triangle wave form

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.

 Respuesta aceptada

Aquatris
Aquatris el 28 de Jun. de 2024
Editada: Aquatris el 28 de Jun. de 2024
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))

Más respuestas (0)

Categorías

Más información sobre Simulink Coder en Centro de ayuda y File Exchange.

Productos

Versión

R2023a

Preguntada:

el 28 de Jun. de 2024

Comentada:

el 16 de Jul. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by