Undefined variable error while the variable was indeed defined right before the use
Afficher commentaires plus anciens
I am sorry to ask this again, but the previous answer was not even helpful.
My question is basically the same as describe here (see link) , but the answer did not explain things well and did not provide realization. I did try to add function handler, not working at all.
Attached code and error below:
%%Calculations
%To and Tw are previsouly imported tables
To.v = To.L / To.T; % unit = m/s
Tw.v = Tw.L / To.T; % unit = m/s
eta_oil = 2.675E-10* exp(5975.4/(16+273))
eta_water = 0.0011076 %unit = Pa*s
rho_oil = 0.878E3 % kg/m^3
rho_water = 1E3 %kg/m^3
rho_n = 1.13E3
rho_b = 8.45E3
To.Re = calcRe(To,0)
function Re = calcRe(T,type)
% Re = Dp*Vp*rho_f/eta_f
if type==0 % oil
Re = T.D .* T.v * rho_oil/eta_oil
else
Re = T.D .* T.v * rho_water/eta_water
end
end
The error is Undefined function or variable 'rho_oil'.
Workspace has eta_oil shown. I have no idea why the "snapshot" does not take eta_oil. Oh by the way, I also tried to declare the variable as global. Cannot resolve with effort. Please help ;-;
2 commentaires
madhan ravi
le 1 Nov 2018
_I have no idea why the "snapshot" does not take eta_oil._
What does that mean?
Kunhuan Liu
le 1 Nov 2018
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Scope Variables and Generate Names dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!