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.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
hüsna özlem mermer
am 17 Mai 2021
Beantwortet: David Hill
am 17 Mai 2021
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 Kommentar
Rik
am 17 Mai 2021
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
Akzeptierte Antwort
David Hill
am 17 Mai 2021
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 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!