how can i change the for loop in this program..?

r=10
P1=10^9 w1=4.55 w2=5.13 h=8; for x=1;2;3;4;5;6;7;8;9;10; d= 20.*x end w=d; d0=0.4 B1=(d./d0).^(1./3) s=d./r; A1=d.^2 E0=8.85*10^-12 b=6.830890 E1=b.*w1.^1.5 E1g=b.*w2.^1.5 E2=E1./B1
E2g=E1g./B1 c=E2.*d./B1 cg=E2g.*d./B1 x=0.5.*E0.*E2.^2.*10^18 xg=0.5.*E0.*E2g.^2.*10^18 A2=A1.*(x./P1) A2g=A1.*(xg./P1) v1=d.*A1 v=(d+h).*(A1+A2) vg=(d+h).*(A1+A2g) u=x.*(v1./v) ug=xg.*(v1./vg) plot(d,u,'green') hold plot(d,ug,'red') hold

3 commentaires

dpb
dpb le 16 Mar 2014
Format the code so we can read it...
an
an le 27 Mar 2014
r=10
P1=10^9 w1=4.55 w2=5.13 h=8; for x=1;2;3;4;5;6;7;8;9;10; d= 20.*x end w=d; d0=0.4 B1=(d./d0).^(1./3) s=d./r; A1=d.^2 E0=8.85*10^-12 b=6.830890 E1=b.*w1.^1.5 E1g=b.*w2.^1.5 E2=E1./B1
E2g=E1g./B1 c=E2.*d./B1 cg=E2g.*d./B1 x=0.5.*E0.*E2.^2.*10^18 xg=0.5.*E0.*E2g.^2.*10^18 A2=A1.*(x./P1) A2g=A1.*(xg./P1) v1=d.*A1 v=(d+h).*(A1+A2) vg=(d+h).*(A1+A2g) u=x.*(v1./v) ug=xg.*(v1./vg) plot(d,u,'green') hold plot(d,ug,'red')

Connectez-vous pour commenter.

 Réponse acceptée

In place of your for-loop you can have:
d = 20*[1:10].';
or
d = linspace(20,200,10);

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by