Plotting functions in matlab

I am having trouble figuring out how to plot functions in matlab. Below are examples of functions I am having trouble with. I don't know what functions to use or even how to write it to where it could be plotted.
f(t) = Kt[u(t+a/2)-u(t-a/2)]
f(t) = Acos(pi*t/2)[u(t+2)-u(t-2)]
f(t) = Ae^(-2(t-1))u(t-1)
I am new to matlab, so anything would be helpful. Thanks.

 Accepted Answer

hi, try as example :
% Constants
K=2.33;
A=1.45;
t=0:0.1:10;
a=0.45;
% Anonymous function
u=@(t) cos(t)
f1=K*t.*(u(t+a/2)-u(t-a/2));
f2=A*cos(pi*t/2).*(u(t+2)-u(t-2));
f3=A*exp(-2*(t-1)).*u(t-1);
figure, plot(t,f1,t,f2,'r',t,f3,'g'), legend('f1','f2','f3');
grid on,

More Answers (0)

Categories

Find more on Graphics Objects in Help Center and File Exchange

Products

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!