Creating Continuous Time Triangle in Matlab
7 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Image Analyst
on 19 Mar 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)
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!