Struggling to use fzero on this function
Afficher commentaires plus anciens
I am trying to solve for when y=0 with u as the variable for the function below.
When I try v= fzero(@(u) velocity(u,-1,250E-6, 0.13))
MATLAB says:
FZERO requires at least two input arguments or a structure with valid fields.
Any ideas?
function y=velocity(u,z,Ro,H)
p_sat = 2.3393E3; Patm = 100E3; rho_f = 998.21; g = 9.81; Pl = Patm-rho_f*g*z; gamma = 7.28E-2;
p =[Pl-p_sat 2*gamma 0 -(Patm+rho_f*g*H)*Ro^3]; R = roots(p); % get all roots of p R = R(imag®==0); % only keep real roots
Vb=(4.*pi.*R^3)./3;
g = 9.81; rho_f = 998.21; temp = 20+273; R_g = 8.3145; y_air = 1-((p_sat)./(Pl.*((Ro./R).^3))); y_water = 1-y_air; Mr = (28.9647./1000).*y_air + (18./1000)*y_water; Pb = Pl+((2.*gamma)/R); rho_b = (Pb./(R_g.*temp)).*Mr; mu = 0.0010005; d = 2.*R;
Re =((rho_f*u*d)/mu) cd =(24/Re)*(1+0.15*Re.^0.687)
y=Vb.*g.*(rho_f-rho_b)-cd.*((pi.*d.^2)/4)*((rho_f*u.^2)/2)
end
Réponse acceptée
Plus de réponses (2)
ZM
le 25 Fév 2018
0 votes
Toluwaloju Tunde Isaiah
le 2 Fév 2021
0 votes
I am trying to solve the following using the fzero command
L=0.035:-0.001:0
for k=1;
while k<=length(L);
L=L(:,k);
fun_=@(x)det([(cosh(x)+cos(x))-(x.^3)*(In/(M*L.^2))*(sinh(x)+sin(x))-(x.^2)*(Ms/(M*L))*(cosh(x)-cos(x)) (sinh(x)+sin(x))-
(x.^3)*(In/(M*L.^2))*(cosh(x)-cos(x))-(x.^2)*(Ms/(M*L))*(sinh(x)-sin(x)); (sinh(x)-sin(x))+(x)*(m0/M)*(cosh(x)-cos(x))+(x.^2)*
(Ms/(M*L))*(sinh(x)+sin(x)) (cosh(x)+cos(x))+(x)*(m0/M)*(sinh(x)-sin(x))+(x.^2)*(Ms/(M*L))*(cosh(x)-cos(x))]);
fun(k)=fzero(@(x)fun_(x));
fun(k)=fzero(@(x)fun_(x,L));
its = [fzero(fun(k),0.1) fzero(fun(k),0.3) fzero(fun(k),0.5) fzero(fun(k),0.7)];
itss = its(its>0);
betaN = min(itss)
wn=(betaN(k)^2)*sqrt(E*I_s/(Rho*A*(L^4)));
fn=wn/(2*pi)
fprintf('Mode shape # %2f corresponds to nat. freq (wn): %f\n', k, wn(k) );
k=k+1;
end
end
M, L, m0, In, Ms, are known scalers
The Line of error feed back i recieved follows
Error using fzero (line 116)
FZERO requires at least two input arguments or a structure with valid fields.
Error in PiezowithTunability (line 55)
fun(k)=fzero(@(x)fun_(x,L));
Catégories
En savoir plus sur Whos 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!