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

Search This Blog

Absolute function plot in MATLAB

Absolute function plot in MATLAB












MAT LAB CODE:

t=-20:0.0001:20;
y=abs(t);
plot(t,y)

Output:

Check the video for clear explanation:



Some sample programs based on above concept:

1)Reflection of y=|x| about x axis:

The reflected signal is y=-|x| , i.e only one line of the code will change →The second line will be y=-abs(x) instead of y=abs(x). So the code will be as below:



t=-20:0.0001:20;
y=-abs(t);
plot(t,y)

Output:


2)Plotting the graph of |x|+|y|=1

We can conclude , the following from the above equation:
|y|=1-|x|=1)y=-1+|x|..........(i)
                2)y=1-|x|............(ii)
From (i) and (ii) equations it is clear the code will be→

x=-20:0.0001:20;
y=-1+abs(x);
plot(x,y)
hold on
y=1-abs(x);
plot(x,y)
hold off
axis([-1 1 -1 1]);

Output:


*I am sure that you understood , why we have taken x axis range from -1 to 1 and y axis range from -1 to 1 (HINT:Because the solution of the 4 equations are (-1,-1),(-1,1),(1,-1),(1,1)




No comments

Popular Posts

Followers