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.

 Réponse acceptée

Youssef  Khmou
Youssef Khmou le 11 Avr 2013

0 votes

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,

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Objects dans Centre d'aide et File Exchange

Produits

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by