Trying to find root of equation with fzero command in Matlab.
Afficher commentaires plus anciens
I want to solve a problem in which I am given a function (seen below) where W is 4.9 and I must find v. I have to use the fzero method but I am having trouble with this as I only know how to find the roots. How can I do this? (Function file and script file ARE separate and below)
function W = dforce(v)
R = 287;
P = 101300;
d = 15;
A = (pi*d^2)/4;
T = linspace(-60,60,121);
b1 = 2.156954157e-14;
b2 = -5.332634033e-11;
b3 = 7.477905983e-8;
b4 = 2.527878788e-7;
mu = b1*T.^3+b2*T.^2+b3*T+b4;
ro = P./(R*T);
Re = (ro*v*d)/mu;
Cd = (24/Re)+(6/(1+sqrt(Re)))+0.4;
W = Cd*0.5*ro*v^2*A;
end
___________________________________________________________________________________ clear all, close all
m = 0.5;
g = 9.8;
N = m*g;
dF = @(v) dforce(v)- N;
V = fzero(dF,0);
1 commentaire
Matt J
le 7 Nov 2014
Please highlight your code and format it using the

button.
Réponses (2)
Orion
le 7 Nov 2014
that seems more logic for me.
use the syntax for using an extraparameter to your function.
% here's an example from the matlab documentation.
myfun = @(x,c) cos(c*x); % parameterized function
c = 2; % parameter
fun = @(x) myfun(x,c); % function of x alone
x = fzero(fun,0.1)
in your case, you should do something like
for T = linspace(-60,60,121);
dF = @(v) dforce(v,T)- N;
V = fzero(dF,0);
end
Catégories
En savoir plus sur Get Started with MATLAB 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!