필터 지우기
필터 지우기

How would I use fzeros in this?

조회 수: 1 (최근 30일)
James Crowe
James Crowe 2017년 12월 8일
답변: M 2017년 12월 8일
Hi I want to use fzeros, but I'm not sure what to do to make it work in my code. You can probably understand what I'm trying to do, so I won't explain. Thank you
f = @myFunction
n = -6:6
x0 = n*pi
z = fzero(f, x0)
  댓글 수: 2
M
M 2017년 12월 8일
x = fzero(fun,x0) tries to find a point x where fun(x) = 0
How is myFunction defined ?
James Crowe
James Crowe 2017년 12월 8일
I have read that and not sure how to do it still. My function is defined as:
function [y] = myFunction(x)
y = 3*sin(5*x)+2*cos(x.^1);
end

댓글을 달려면 로그인하십시오.

답변 (1개)

M
M 2017년 12월 8일
If you read the documentation, you should have notice that second input argument must be a scalar or a 2-elements vector.
This is not the case with your example.
Try with
f = @myFunction
x0 =[1 -1];
z = fzero(f, x0);
myFunction(z)
ans =
-4.4409e-16
or
f = @myFunction
x0=0;
z = fzero(f, x0);
myFunction(z)
ans =
0

카테고리

Help CenterFile Exchange에서 Nonlinear Regression에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by