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.

 采纳的回答

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,

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Graphics Objects 的更多信息

产品

标签

Community Treasure Hunt

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

Start Hunting!

Translated by