필터 지우기
필터 지우기

Error Using fzero function

조회 수: 1 (최근 30일)
N/A
N/A 2020년 2월 12일
댓글: Walter Roberson 2020년 2월 12일
Keep receiving error message when using the code below. I am attempting to solve for m.
function FZERO_P(s0,s1)
x0=[s0 s1];
g=9.81;
v=35;
t=8;
c=15;
x=fzero(@(m) (g*m/c)*(1-exp^(-c*t/m))-v, x0)
end
ERROR:
FZERO cannot continue because user-supplied function_handle ==> @(x)(g*x/c)*(1-exp^(-c*t/x))-v failed with the
error below.
Not enough input arguments.
Error in FZERO_P (line 7)
x=fzero(@(x) (g*x/c)*(1-exp^(-c*t/x))-v, x0)
  댓글 수: 2
KSSV
KSSV 2020년 2월 12일
Keep receiving error message how do you expect us to help you with only this information? You shoudl mention what is the error? What and how you have done?
Walter Roberson
Walter Roberson 2020년 2월 12일
You are not passing a parameter to exp. exp with no arguments is not the transcendental constant e that might then be raised to a power. If you must have the constant then use exp(1) . However, using exp(x) is going to be more accurate than exp(1)^x

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

채택된 답변

Walter Roberson
Walter Roberson 2020년 2월 12일
x=fzero(@(m) (g*m/c).*(1-exp(-c*t./m))-v, x0)
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 2월 12일
Note that the expected results are a vector of two values that are the same because you are doing the same calculation for the two values in x. If there are two solutions then it is possible that you will get a vector of different values but not certain.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by