필터 지우기
필터 지우기

if function error, here i want MatLab to find the values of V5L that are between 1 and 4.5 and name it V, and use it in another upcoming equation

조회 수: 1 (최근 30일)
clear,clc,clf
Q=3.3;
D5L=[12.75*0.0254 14*0.0254 16*0.0254 18*0.0254 20*0.0254 22*0.0254 24*0.0254 26*0.0254 28*0.0254 30*0.0254 32*0.0254 34*0.0254 36*0.0254 38*0.0254 40*0.0254 42*0.0254 44*0.0254 46*0.0254 48*0.0254 52*0.0254 56*0.0254 60*0.0254 64*0.0254 68*0.0254 72*0.0254 76*0.0254 80*0.0254]
V5L=((4.*Q)./(pi.*D5L.^2));
if V5L > 1 & V5L < 4.5
V=V5L
end
Do=((4.*Q)./(pi.*V)).^(0.5)

채택된 답변

Star Strider
Star Strider 2019년 1월 27일
편집: Star Strider 2019년 1월 27일
This works for me:
Q = 3.3;
D5L = [12.75*0.0254 14*0.0254 16*0.0254 18*0.0254 20*0.0254 22*0.0254 24*0.0254 26*0.0254 28*0.0254 30*0.0254 32*0.0254 34*0.0254 36*0.0254 38*0.0254 40*0.0254 42*0.0254 44*0.0254 46*0.0254 48*0.0254 52*0.0254 56*0.0254 60*0.0254 64*0.0254 68*0.0254 72*0.0254 76*0.0254 80*0.0254];
V5L = ((4.*Q)./(pi.*D5L.^2));
V = V5L((V5L > 1) & (V5L < 4.5));
Do = sqrt((4.*Q)./(pi.*V))
producing:
Do =
1.0160 1.0668 1.1176 1.1684 1.2192 1.3208 1.4224 1.5240 1.6256 1.7272 1.8288 1.9304 2.0320
EDIT — (27 Jan 2019 at 15:09)
This runs for me without error (in R2018b):
Q=3.3;
%gamma=8.43 kN/m3 = 859.62076503 Kg/m3 (*1000/9.81)
rouh=859.62076503;
g=9.81;
Gamma=(rouh.*g);
Zs=0;
Ze=0;
L=1285000;
Ks=(0.000045);
Er=(1E-8);
viscosity=(3.83.*1E-3);
% material grade X70
strength= 482000000;
%API 5L
% % D5L=[12.75*0.0254 14*0.0254 16*0.0254 18*0.0254 20*0.0254 22*0.0254 24*0.0254 26*0.0254 28*0.0254 30*0.0254 32*0.0254 34*0.0254 36*0.0254 38*0.0254 40*0.0254 42*0.0254 44*0.0254 46*0.0254 48*0.0254 52*0.0254 56*0.0254 60*0.0254 64*0.0254 68*0.0254 72*0.0254 76*0.0254 80*0.0254]
% % V5L=((4.*Q)./(pi.*D5L.^2));
% % if V=V5L(V5L > 1 & abs(V5L - 4.5<1e-5));
% % end
% % Do=((4.*Q)./(pi.*V)).^(0.5)
D5L = [12.75*0.0254 14*0.0254 16*0.0254 18*0.0254 20*0.0254 22*0.0254 24*0.0254 26*0.0254 28*0.0254 30*0.0254 32*0.0254 34*0.0254 36*0.0254 38*0.0254 40*0.0254 42*0.0254 44*0.0254 46*0.0254 48*0.0254 52*0.0254 56*0.0254 60*0.0254 64*0.0254 68*0.0254 72*0.0254 76*0.0254 80*0.0254];
V5L = ((4.*Q)./(pi.*D5L.^2));
V = V5L((V5L > 1) & (V5L < 4.5));
Do = sqrt((4.*Q)./(pi.*V));
Re=(V.*Do./viscosity);
Fo=0.01;
for I=0:1:1E6;
Fn=(1./(-4.*log10((Ks./(3.71.*Do))+((1.26)./(Re.*sqrt(Fo)))))).^2;
E=abs((Fn-Fo)/Fn);
if E<=Er;
Fn=Fn(end);
display(E)
break
end
if E>Er;
Fo=Fn;
end
end
Hloss=((Fn.*L.*Q.^2)./(12.*Do.^5));
Hpump=Hloss+Ze-Zs;
%calculating Hloss every 128500M
LC=1:128500:1285000;
for i=1:1:length(LC);
Hpump=Hloss+Ze-Zs;
PRESSURE=rouh.*g.*Hpump.*1E-5;
numberofpumps=ceil(PRESSURE./90);
pressureperpump=(PRESSURE./numberofpumps);
HlossN=((Fn.*LC(i).*Q.^2)./(12.*sqrt(Do)));
TEL(i,:)=(Hpump-HlossN+Zs);
HGL(i,:)=(TEL(i,:)-((V.^2)./(2.*g)));
PE=Gamma.*(HGL-Ze);
T=((PE(i).*Do)./(2.*strength));
end
for ii=1:1:length(Do)
subplot(4,4,ii)
plot(LC,TEL(:,ii))
hold on
plot(LC,HGL(:,ii))
xlabel('LC')
ylabel('HGL & TEL')
end

추가 답변 (1개)

madhan ravi
madhan ravi 2019년 1월 27일
편집: madhan ravi 2019년 1월 27일
EDITED
clear all
Q=3.3;
D5L=[12.75*0.0254 14*0.0254 16*0.0254 18*0.0254 20*0.0254 22*0.0254 24*0.0254 26*0.0254 28*0.0254 30*0.0254 32*0.0254 34*0.0254 36*0.0254 38*0.0254 40*0.0254 42*0.0254 44*0.0254 46*0.0254 48*0.0254 52*0.0254 56*0.0254 60*0.0254 64*0.0254 68*0.0254 72*0.0254 76*0.0254 80*0.0254]
V5L=((4.*Q)./(pi.*D5L.^2));
V=V5L(V5L > 1 & V5L < 4.5);
Do=((4.*Q)./(pi.*V)).^(0.5);
  댓글 수: 4
omar mahallawy
omar mahallawy 2019년 1월 27일
clear,clc,clf
format short
Q=3.3;
%gamma=8.43 kN/m3 = 859.62076503 Kg/m3 (*1000/9.81)
rouh=859.62076503;
g=9.81;
Gamma=(rouh.*g);
Zs=0;
Ze=0;
L=1285000;
Ks=(0.000045);
Er=(1.*10.^-8);
viscosity=(3.83.*10.^-3);
% material grade X70
strength= 482000000;
%API 5L
D5L=[12.75*0.0254 14*0.0254 16*0.0254 18*0.0254 20*0.0254 22*0.0254 24*0.0254 26*0.0254 28*0.0254 30*0.0254 32*0.0254 34*0.0254 36*0.0254 38*0.0254 40*0.0254 42*0.0254 44*0.0254 46*0.0254 48*0.0254 52*0.0254 56*0.0254 60*0.0254 64*0.0254 68*0.0254 72*0.0254 76*0.0254 80*0.0254]
V5L=((4.*Q)./(pi.*D5L.^2));
if V=V5L(V5L > 1 & abs(V5L - 4.5<1e-5));
end
Do=((4.*Q)./(pi.*V)).^(0.5)
Re=(V.*Do./viscosity)
Fo=0.01;
for I=0:1:10^6;
Fn=(1./(-4.*log10((Ks./(3.71.*Do))+((1.26)./(Re.*sqrt(Fo)))))).^2;
E=abs((Fn-Fo)/Fn);
if E<=Er;
Fn=Fn(end),display(E),break,
end
if E>Er;
Fo=Fn;
end
end
Hloss=((Fn.*L.*Q.^2)./(12.*Do.^5))
Hpump=Hloss+Ze-Zs
%calculating Hloss every 128500M
LC=1:128500:1285000;
for i=1:1:length(LC);
Hpump=Hloss+Ze-Zs
PRESSURE=rouh.*g.*Hpump.*10.^(-5)
numberofpumps=ceil(PRESSURE./90)
pressureperpump=(PRESSURE./numberofpumps)
HlossN=((Fn.*LC(i).*Q.^2)./(12.*Do.^5))
TEL(i,:)=(Hpump-HlossN+Zs)
HGL(i,:)=(TEL(i,:)-((V.^2)./(2.*g)))
PE=Gamma.*(HGL-Ze)
T=((PE(i).*Do)./(2.*strength))
end
for ii=1:1:length(Do)
subplot(4,4,ii)
plot(LC,TEL(:,ii))
hold on
plot(LC,HGL(:,ii))
xlabel('LC')
ylabel('HGL & TEL')
end
madhan ravi
madhan ravi 2019년 1월 27일
clear,clc,clf
format short
Q=3.3;
%gamma=8.43 kN/m3 = 859.62076503 Kg/m3 (*1000/9.81)
rouh=859.62076503;
g=9.81;
Gamma=(rouh.*g);
Zs=0;
Ze=0;
L=1285000;
Ks=(0.000045);
Er=(1.*10.^-8);
viscosity=(3.83.*10.^-3);
% material grade X70
strength= 482000000;
%API 5L
D5L=[12.75*0.0254 14*0.0254 16*0.0254 18*0.0254 20*0.0254 22*0.0254 24*0.0254 26*0.0254 28*0.0254 30*0.0254 32*0.0254 34*0.0254 36*0.0254 38*0.0254 40*0.0254 42*0.0254 44*0.0254 46*0.0254 48*0.0254 52*0.0254 56*0.0254 60*0.0254 64*0.0254 68*0.0254 72*0.0254 76*0.0254 80*0.0254]
V5L=((4.*Q)./(pi.*D5L.^2));
V=V5L(V5L > 1 & abs(V5L - 4.5<1e-5));
Do=((4.*Q)./(pi.*V)).^(0.5)
Re=(V.*Do./viscosity)
Fo=0.01;
for I=0:10^6
Fn=(1./(-4.*log10((Ks./(3.71.*Do))+((1.26)./(Re.*sqrt(Fo)))))).^2;
E=abs((Fn-Fo)/Fn);
if E<=Er
Fn=Fn(end);
display(E)
break
else
Fo=Fn;
end
end
Hloss=((Fn.*L.*Q.^2)./(12.*Do.^5));
Hpump=Hloss+Ze-Zs;
%calculating Hloss every 128500M
LC=1:128500:1285000;
TEL=zeros(numel(LC),numel(Do));
HGL=zeros(numel(LC),numel(Do));
PE=zeros(numel(LC),numel(Do));
T=zeros(numel(LC),numel(Do));
for k=1:numel(LC)
HlossN=((Fn.*LC(k).*Q.^2)./(12.*Do.^5));
TEL(k,:)=(Hpump-HlossN+Zs);
HGL(k,:)=(TEL(k,:)-((V.^2)./(2.*g)));
PE(k,:)=Gamma.*(HGL(k,:)-Ze);
T(k,:)=((PE(k,:).*Do)./(2.*strength));
end
for ii=1:numel(Do)
subplot(4,4,ii)
plot(LC,TEL(:,ii))
hold on
plot(LC,HGL(:,ii))
xlabel('LC')
ylabel('HGL & TEL')
end

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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by