필터 지우기
필터 지우기

why "if loop" contents not getting computed?

조회 수: 1 (최근 30일)
an
an 2014년 3월 27일
댓글: an 2014년 3월 28일
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

채택된 답변

Joseph Cheng
Joseph Cheng 2014년 3월 27일
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
an
an 2014년 3월 28일
I want if statement to be like this if s1<2 ,e1=1 s1=2 ,e1=(s+2)/4 s1>2, e1=s/4

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by