Generation of triangle wave

This function allows the generation of a triangular wave.

You are now following this Submission

The usage is the same as sin(2*pi*f*t), but the triangular wave is generated with an amplitude between 0 and 1.
So to generate one second of a triangle wave of amplitude 2 with frequency 5 Hz (sampled each millisecond)

f = 5;
t = 0:0.001:1;
A = 2;
wave = A*triangle(2*pi*f*t);

Note: the wave is generated with positive amplitude (i.e. centered around half of the amplitude). Check the comment in the code to easily change this behaviour.

Cite As

Michele Antolini (2026). Generation of triangle wave (https://uk.mathworks.com/matlabcentral/fileexchange/46987-generation-of-triangle-wave), MATLAB Central File Exchange. Retrieved .

Categories

Find more on Random Number Generation in Help Center and MATLAB Answers

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.2.0.0

Changed title and description

1.1.0.0

new tags

1.0.0.0