필터 지우기
필터 지우기

Multiple fminbnd errors with a parametrized function

조회 수: 2 (최근 30일)
Cassandra Meyer
Cassandra Meyer 2022년 3월 25일
댓글: Cassandra Meyer 2022년 3월 25일
I am trying to use fminbnd for this function, where I was given parametrizations to plug in. It keeps giving me errors and I'm not sure what they mean. Any advice would be appreciated.
fun = exp(cos(t)) - sin((3^(1/2)*sin(t))/3);
t1 = 0;
t2 = 2*pi;
fminbnd(fun, t1, t2)
Error using fcnchk (line 107)
If FUN is a MATLAB object, it must have an feval method.
Error in fminbnd (line 198)
funfcn = fcnchk(funfcn,length(varargin));
Error in sevenbi (line 10)
fminbnd(fun, t1, t2)

채택된 답변

Torsten
Torsten 2022년 3월 25일
You are in the realm of numerical, not symbolic computations.
Here, functions are defined as handles:
fun = @(t) exp(cos(t)) - sin((3^(1/2)*sin(t))/3);
  댓글 수: 1
Cassandra Meyer
Cassandra Meyer 2022년 3월 25일
Ohhh yup I was trying the @ symbol but forgot to define t. Thanks!!

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

추가 답변 (1개)

Catalytic
Catalytic 2022년 3월 25일
Here is a symbolic method, if that's what you wanted.
syms t f(t)
f(t) = exp(cos(t)) - sin((3^(1/2)*sin(t))/3);
vpasolve(diff(f,t)==0,[0,2*pi])
ans = 
6.0708220544184582393726949540477

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by