필터 지우기
필터 지우기

I want to find R, but it says I have error on using fzero

조회 수: 1 (최근 30일)
kanghao he
kanghao he 2016년 12월 6일
댓글: Roger Stafford 2016년 12월 6일
a=2.1.*10.^-3;
b=2.9.*10.^-4;
c=8.7.*10.^-8;
T=322 %Kelvins
resistance=@(R)(T(a+b.*log(R)+c.*(log(R)).^3)); %ohm
solution=fzero(resistance,200)
  댓글 수: 1
Roger Stafford
Roger Stafford 2016년 12월 6일
You don’t need to use ‘fzero’ in this equation. First solve the cubic equation for log( R ) using ‘roots’, and then solve for R using the ‘exp’ function, assumed your logs are natural logs, or powers of ten assuming the logs are base ten.

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

답변 (1개)

Steven Lord
Steven Lord 2016년 12월 6일
Your function is:
resistance=@(R)(T(a+b.*log(R )+c.*(log(R )).^3));
What is element (a+b.*log(R )+c.*(log(R )).^3) of the array T? Does that even evaluate to an integer value suitable for use as an index into an array? [That seems highly unlikely given your values of a, b, and c.]
I think you forgot an arithmetic operation (I'm guessing a minus sign) in your function.
  댓글 수: 3
Steven Lord
Steven Lord 2016년 12월 6일
No, you did post them. I recommend you go back and check that you've correctly written the function you intend to solve, because I'm pretty sure you didn't copy it into MATLAB correctly based on the plots I made.
Walter Roberson
Walter Roberson 2016년 12월 6일
Steven is pointing out that you have T(expression) and that in MATLAB that is an indexing operation. Perhaps you meant T*(expression) or T-(expression)

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

Community Treasure Hunt

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

Start Hunting!

Translated by