MATLAB: What am i doing wrong in this code

graphs

Best Answer

Looks like you have a piecewise function at the very beginning. If you have Symbolic Toolbox, it will be really easy for you to implement it and plot whatever you want. Try this:
syms t
x(t)=piecewise(t>=0 & t<=1,1,t>1,-t+2);
figure(1)
a=0;b=1;
t=0-a:0.01:2-a;
plot(b^-1*t,x(b*t));grid on;title('x(t)')
figure(2)
a=1;b=1;
t=0-a:0.01:2-a;
plot(b^-1*t,x(b*t+a));grid on;title('x(t+1)')
figure(3)
a=1;b=1;
t=0-a:0.01:2-a;
plot(sort(-(b^-1*t),'ascend'),x(-(b*t)+a));grid on;title('x(-t+1)')
figure(4)
a=0;b=1.5;
t=0-a:0.001:2-a;
plot(t,x(b*t+a));grid on;title('x((3/2)*t)')
figure(5)
a=1;b=1.5;
t=0-a:0.01:2-a;
plot(t,x(b*t+a));grid on;title('x((3/2)*t+1)')