I want to calculate each v value from each diameter value, then the value of Re one by one, and for all the calculations in the for loop,but this code give me single value for v, Re, f . Where am I doing wrong? Sorry I'm beginner in mtlab.
3 ビュー (過去 30 日間)
古いコメントを表示
clc;
close all;
clear;
L=(2000+(5*50))
T=5+5*0.25
It=0.0075*L
ht=0.15*T
bt=0.50*It
e=0.0003*(5+50)
t=15000/sqrt(9.81/ht)
V=It*ht*bt
flwrt=V/t
iteration=1;
for D=0.1:0.01:0.5
v=4*flwrt/pi*D;
Re=(v*D)/0.00000131;
f=1.325/(log10(e/D*3.7+5.74/Re^0.9));
hp=5+5*0.25+(v^2)/2*9.81*[f*(2000+5*50)/D+8.1];
totalhead(iteration)=(v^2)/2*9.81*[f*(2000+5*50)/D+8.1];
Ppower(iteration)=((9.81*1000*flwrt*hp)/1000);
valvecost=320+(D/25)*200;
elbowcost=60+((D/25)*50);
pipecost=(2000+5*50)/25*1,5;
pumpandmotorcost=3700+100*ht;
electricitycost=(0.15*(t/3600)*Ppower);
yearelectric=electricitycost*730;
totalcost(iteration)=(elbowcost+valvecost)*5
ttcst=(pipecost+pumpandmotorcost+electricitycost)*5
a=totalcost+ttcst
htVals(iteration)=ht;
iteration=iteration+1;
end
plot(0.1:0.01:0.5,totalhead)
hold on
plot(0.1:0.01:0.5,Ppower)
hold on
plot(0.1:0.01:0.5,a)
hold on
1 件のコメント
Rik
2021 年 5 月 17 日
This time I edited your question for you. Next time, please use the tools explained on this page to make your question more readable. You should also use the default indentation.
If you had used the debugging tools to step through your code line by line, you would have noticed that Re will be overwritten every iteration. If you want a vector, you will have to index it:
D_list=0.1:0.01:0.5;
Re=zeros(size(D_list));
for n=1:numel(D_list)
D=D_list(n);
v=4*flwrt/pi*D;
Re(n)=(v*D)/0.00000131;
...
end
採用された回答
David Hill
2021 年 5 月 17 日
No loop needed.
L=(2000+(5*50));
T=5+5*0.25;
It=0.0075*L;
ht=0.15*T;
bt=0.50*It;
e=0.0003*(5+50);
t=15000/sqrt(9.81/ht);
V=It*ht*bt;
flwrt=V/t;
D=0.1:0.01:0.5;
v=4*flwrt/pi*D;
Re=(v.*D)/0.00000131;
f=1.325./(log10(e./D*3.7+5.74./Re.^0.9));
hp=5+5*0.25+(v.^2)/2*9.81.*(f*(2000+5*50)./D+8.1);
totalhead=(v.^2)/2*9.81.*(f*(2000+5*50)./D+8.1);
Ppower=((9.81*1000*flwrt*hp)/1000);
valvecost=320+(D/25)*200;
elbowcost=60+((D/25)*50);
pipecost=(2000+5*50)/25*1.5;
pumpandmotorcost=3700+100*ht;
electricitycost=(0.15*(t/3600)*Ppower);
yearelectric=electricitycost*730;
totalcost=(elbowcost+valvecost)*5;
ttcst=(pipecost+pumpandmotorcost+electricitycost)*5;
a=totalcost+ttcst;
htVals=ht;
plot(D,totalhead);
figure;
plot(D,Ppower);
figure;
plot(D,a);
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!