Creating Continuous Time Triangle in Matlab

5 visualizaciones (últimos 30 días)
Curtis
Curtis el 19 de Mzo. de 2013
I need to create a continuous time triangle wave in Matlab that follows the following Pseudo Code:
Triangle = { 1 - abs(t/2) for -2<=t<=2 0 otherwise
Basically, I want a triangle centered on 0, with a max height of 1, that goes from -2 to 2.
I can do it in discrete time with the following code:
a = 2;
t = -a:0.001:a; %define time from -2 to 2
triangle = 1-abs(t/a); %triangle function with max height of 1.
plot(t,triangle)
but I haven't the foggiest how to make this into a continuous time function. Any help would be greatly appreciated.

Respuestas (1)

Image Analyst
Image Analyst el 19 de Mzo. de 2013
Use repmat().
a = 2;
t = -a:0.001:a; %define time from -2 to 2
triangle = 1-abs(t/a); %triangle function with max height of 1.
numberOfReplications = 3;
triangleWave = repmat(triangle, [1, numberOfReplications]);
plot(triangleWave)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by