Hey, I want to plot P(x) over x=-10:0.5:20
P(x) is defined asP(x)= x for 0=<x=<1; = 2-x for 1<=x<=2;P(x) is zero at other points.
For this I have written following code:
dx=1; xx=1:dx:20;for i=1:1:20; fp(1,i)=bilinear(i);endplot(xx',fp');function [ z ] = bilinear( x )if (1>=x>=0) z=x;elseif (2>=x>=1) z=2-x;else z=0;endend
But after running this code, I am not getting the triangular plot which I want. Can somebody tell me where is my logic wrong?
Thanks in advance,
Nikhil
Best Answer