Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

why i am not getting the plot while giving the following program with if else statyement?please help

1 vue (au cours des 30 derniers jours)
an
an le 6 Mar 2014
Clôturé : MATLAB Answer Bot le 20 Août 2021
r=10; d=[1 100 1000]; P1=10^9; P2=130*10^9; s=d./r;
a=0; c=2; x=s; if (a<=x<=2); e1=1; else if (x>=2); e1=((d./r)+2)./4; else if (x>2); e1=(d./r)./4; end end end
u=e1.*P1; ug=e1.*P2; plot(d,u,'green') hold; plot(d,ug ,'red');

Réponses (1)

Chandrasekhar
Chandrasekhar le 6 Mar 2014
r=10; d=[1 100 1000]; P1=10^9; P2=130*10^9; s=d./r;
a=0; c=2; x=s;
if (a<=x<=2)
e1=1;
else if (x>=2)
e1=((d./r)+2)./4;
else if (x>2)
e1=(d./r)./4;
end
end
end
u=e1.*P1;
ug=e1.*P2;
plot(d,u,'green')
hold;
plot(d,ug ,'red');
  2 commentaires
an
an le 6 Mar 2014
still it is not showing any plots.its coming like dots only
Chandrasekhar
Chandrasekhar le 6 Mar 2014
Modifié(e) : Chandrasekhar le 6 Mar 2014
yes, thats because d and u are scalars. they should be vectors if you want to represent in the form of a graph

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by