if loop not working..please help.

1 次查看(过去 30 天)
clc
clear all
Pc=620*10^6
Pa=62*10^9
Ps=1*10^9
r=10
d0=0.4
d=1:5:100
s=(d./r)
s1=s
w1=4.3
w2=4.66
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)
i=2
e1=1
if s<i;
e1=1;
elseif (s>i)
e1=s./4
else
e1=(s+2)./4
end
x1=e1
  1 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2014-3-28
How it's not working? any error message? are you expecting another result?

请先登录,再进行评论。

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2014-3-28
Replace the If/else by
e1=ones(size(s))
idx1=s>i;
e1(idx1)=s(idx1)/4
idx2=s==i;
e1(idx2)=(s(idx2)+2)/4
x1=e1
  2 个评论
an
an 2014-3-28
Thank You..this works,but i dint understood what this represents. can you please explain what for this ones(size(s)) and idx1 represens

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by