Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

Triangular wave in MATLAB without any builtin function

Triangular wave in MATLAB without any builtin function:

Algorithm:

1) Define the range of t (Here no need to take small increment , if you are following this process)
2)Toggle x value in between 0 and 1
3)Correponding  to each t value , give the x value which is going to be periodically 0 and 1.
4)The t and x length should have same length.
5)Plot x w.r.t t.
And that's all.

Check this video :


*You can make more efficient code with this basic concept using loops or conditional statement.

Code:


t=0:10;

x=[1 0 1 0 1 0 1 0 1 0 1];
plot(t,x);

Output:





Please follow us:
https://www.facebook.com/matlabcodes

Join us on Telegram:
https://t.me/joinchat/Hu4Nk1EMjOMZ223kakzSWQ

Join us on Facebook Group:
https://www.facebook.com/groups/matlabcodes

No comments

Popular Posts

Followers