Trying to find root of equation with fzero command in Matlab.
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Orion
2014년 11월 7일
Why is T a vector ?
usually, fzero is used to solve an equation to find one scalar solution.
Orion
2014년 11월 7일
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!