GUI Work with plotting time v temp

3 次查看(过去 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.

请先登录,再进行评论。


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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by