Filter löschen
Filter löschen

why "if loop" contents not getting computed?

1 Ansicht (letzte 30 Tage)
an
an am 27 Mär. 2014
Kommentiert: an am 28 Mär. 2014
clc
clear all
Pc=620*10^6
Pa=62*10^9
Ps=1*10^9
r=10
d0=0.4
d=[10 20 30 40 50 60 70 80 90 100]
s=(d./r)
k1=1
k2=(s+2)./4
k3=s./4
s1=s
w1=4.3
E0=8.85*10^-12
Eb=6.830890.*(w1.^(3/2))
B1=(d./d0).^(1/3)
l=(Eb./B1)
m= (2.*Pc./E0).^(1/2)
n=(8.*Pa./(E0.*(1+s).^4)).^(1/2)
x1=min(m,n)
Es=min(x1,l)
l1= 0.5.*E0.*l.^2.*10^18
n1=(4.*Pa)./((1+(s)).^4)
y1=min(l1,Pa)
y2=min(y1,n1)
if s1<2
e1=k1
elseif s1>=2
e1=k2
else s1>2
e1=k3
end

Akzeptierte Antwort

Joseph Cheng
Joseph Cheng am 27 Mär. 2014
if statements do not work this way. how it is written is if all of s1 is <2. I would suggest read the document on if statements and write a for loop or something like this.
e1(s1<2) = k1; %which says for the index positions where s1 < 2 substitute k1 into e1.
i do not understand what you are doing with s1>2. or should the second nested if statement be s1==2?
  1 Kommentar
an
an am 28 Mär. 2014
I want if statement to be like this if s1<2 ,e1=1 s1=2 ,e1=(s+2)/4 s1>2, e1=s/4

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by