function [ y ] = mainFunc( v )
d = 0.15; % Diameter of sphere, meters
g = 9.8; % acceleration due to gravitym m/s^2
m = 0.5; % mass of sphere in kg
P = 101300; % N/m^2
R = 287; %gas cosntant
% Viscosisty constants b1 = 2.156954157e-14;
b2 = -5.332634033e-11;
b3 = 7.477905983e-8;
b4 = 2.527878788e-7;
T = linspace(213,333, 241); %temp in Kelvin
rho = 0*T;
u = 0*T;
for i = 1:length(T)
u(i) = b1*T(i)^3 + b2*T(i)^2 + b3*T(i) + b4;
end
for i = 1:length(T)
rho(i) = P / (R*T(i));
end
y = (24./(rho.*v*d./u) + 6./(1 + sqrt.(rho.*v*d./u)) + 0.4 – m*g) * (1/2) .* rho * v^2 * ((pi*d^2)/4) ;
end
ERROR MESSAGE >
HW5Error using fzero (line 289)FZERO cannot continue because user supplied function_handle ==> mainFunc failed with the error below. Argument to dynamic structure reference must evaluate to a valid field name.
Error in HW5 (line 3) z = fzero(fun,x0)
Best Answer