How to define and plot a piecewise time dependent function
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Numeric Types in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!