GUI Work with plotting time v temp

조회 수: 7 (최근 30일)
kileigh palmer
kileigh palmer 2020년 12월 6일
댓글: VBBV 2020년 12월 8일
Hello lovely people!
I am attempting to create a code that plots Temperature vs time, the first bit of code on (a) is me doing the math for 50 and 140 temperature. After that is loop where I define the density and viscocity at different temperatures, but it won't do the equation like I wanted to. Any suggestions?
%% GUI #2
volume = 0.0125 % in ft3
D = 0.73/12 % in ft
density = 1.94 % at 50 F
den = 1.91 % at 140 F
vi = 2.73*(10^-5) % for 50 F
visc = 0.974*(10^-5) % for 140 F
Vel50 = (2100*vi)/(density*D) % ans in ft/s % velocity at 50 F
Vel140 = (2100*visc)/(den*D)
t = (4*volume)/(pi*(D^2)*Vel50) % ans in seconds time at 50 F
t140 = (4*volume)/(pi*(D^2)*Vel140) % ans in seconds
% B
Vel5 = (4000*vi)/(density*D) % ans in ft/s
Vel14 = (4000*visc)/(den*D)
t = (4*volume)/(pi*(D^2)*Vel5) % ans in seconds
t140 = (4*volume)/(pi*(D^2)*Vel14) % ans in seconds
% Graph at various water temperatures
dens = [1.940 1.938 1.931 1.908 1.869]; % different densities at temps from chart in book
for k = 1:numel(dens)
if dens == 1.940
vi = 3.732*(10^-5)
disp('Temperature of water is 32 F')
T = 32;
elseif dens == 1.938
vi = 2.344*(10^-5)
disp('Temperature of water is 60 F')
T = 60;
elseif dens == 1.931
vi = 1.5*(10^-5)
disp('Temperature of water is 90 F')
T = 90;
elseif dens == 1.908
vi = 9.743*(10^-6)
disp('Temperature of water is 140 F')
T = 140;
elseif dens == 1.869
vi = 6.342*(10^-6)
disp('Temperature of water is 200 F')
T = 200;
end
Vel(k) = (2100*vi)/(dens*D)
end
for j = 1:numel(Vel)
tk = (4*volume)/(pi*(D^2)*Vel)
end
Tf = [32 60 90 140 200]
plot(Tf,Vel)

답변 (2개)

VBBV
VBBV 2020년 12월 6일
You can change the for loop structure to below and plot time vs emp
for k = 1:numel(dens)
if dens(k) == 1.940
vi = 3.732*(10^-5)
disp('Temperature of water is 32 F')
T(k) = 32;
Vel(k) = (2100*vi)/(dens(k)*D)
tk(k) = (4*volume)/(pi*(D^2)*Vel(k))
elseif dens(k) == 1.938
vi = 2.344*(10^-5)
disp('Temperature of water is 60 F')
T(k) = 60;
Vel(k) = (2100*vi)/(dens(k)*D)
tk(k) = (4*volume)/(pi*(D^2)*Vel(k))
elseif dens(k) == 1.931
vi = 1.5*(10^-5)
disp('Temperature of water is 90 F')
T(k) = 90;
Vel(k) = (2100*vi)/(dens(k)*D)
tk(k) = (4*volume)/(pi*(D^2)*Vel(k))
elseif dens(k) == 1.908
vi = 9.743*(10^-6)
disp('Temperature of water is 140 F')
T(k) = 140;
Vel(k) = (2100*vi)/(dens(k)*D)
tk(k) = (4*volume)/(pi*(D^2)*Vel(k))
elseif dens(k) == 1.869
vi = 6.342*(10^-6)
disp('Temperature of water is 200 F')
T(k) = 200;
Vel(k) = (2100*vi)/(dens(k)*D)
tk(k) = (4*volume)/(pi*(D^2)*Vel(k))
end
end
plot(T,Vel,'-b',tk,T,'-r.')
legend('Temp vs Vel','Time vs Temp')
  댓글 수: 15
Walter Roberson
Walter Roberson 2020년 12월 8일
VBBV: I think they are using App Designer instead of GUIDE.
VBBV
VBBV 2020년 12월 8일
Yeah you're right

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


Walter Roberson
Walter Roberson 2020년 12월 6일
if ismembertol(dens(i), 1.940)
  댓글 수: 2
kileigh palmer
kileigh palmer 2020년 12월 6일
After that is says Array indices must be positive integers or logical values.
Walter Roberson
Walter Roberson 2020년 12월 6일
if ismembertol(dens(k), 1.940)

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

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by