How to define and plot a piecewise time dependent function
Afficher commentaires plus anciens
Hello!
I am trying to plot a function that has a certain y value when it is between two variables, but I keep getting an error that reads:
Operands to the || and && operators must be convertible to logical scalar values.
for this line:
if (0<=t) && (t<=e)
Please help!
e = 1;
t=linspace(0,10);
l=numel(t);
for i=1:l
if (0<=t) && (t<=e)
y(i) = (pi/(2*e))*sin((pi/e)*t);
else
y(i) = 0;
end
plot(t,y)
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Numeric Types dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!