How to plot 3 functions inside if loop??
Afficher commentaires plus anciens
function y=h(x,a,b,lf,t)
v=length(x);
for i=1:1:v
Q=((a-(2*a+lf-x(i)))/a)^2;
Z=sqrt(1-Q);
S=((a-x(i))/a)^2;
T=sqrt(1-S);
if ((x(i)>=(lf+a))&&(x(i)<=(lf+2*a)))
plot y(i)=((2*b)+(t)-((2.*b).*Z));
end;
if ((x(i)>=0)&&(x(i)<=a))
plot y(i)=((2*b)+(t)-2*b*T);
end;
if ((x(i)>=a)&&(x(i)<=(lf+a)))
plot y(i)=(t);
end;
end;
Réponses (2)
Image Analyst
le 11 Juin 2013
Look up plot() in the help. You're not even close to using it correctly. You need to set up y on a separate line, then do
y = 2*b.....whatever.
plot(t, y, 'b-');
hold on;
I don't believe the loop over i is even needed.
Catégories
En savoir plus sur Graphics Performance 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!