필터 지우기
필터 지우기

How do i use fzero to solve the following

조회 수: 1 (최근 30일)
Liam Wiltshire
Liam Wiltshire 2018년 1월 9일
댓글: Liam Wiltshire 2018년 1월 9일
My code reads as follows:
time2 = [0:1:4000];
y = log10(62) - log10(49) - 0.000084*time2;
fzero(y,1200)
I need to use fzero to calculate the value of time2 when the above equasion is zero. I don't know why it wont work as above but despite my best efforts nothing will stick.
Cheers
p.s. i need to use fzero so alternative solutions, whilst welcome, won't solve my problem.

채택된 답변

Stephen23
Stephen23 2018년 1월 9일
편집: Stephen23 2018년 1월 9일
That is not how to use fzero. As its help clearly states and shows, the first argument must be a function handle, which you have not provided. Try this:
>> fun = @(t) log10(62) - log10(49) - 0.00008*t;
>> fzero(fun,1200)
ans = 1277.4
and reading the MATLAB documentation.
  댓글 수: 3
Stephen23
Stephen23 2018년 1월 9일
@Torsten: I think the y in the question is a red herring.
Liam Wiltshire
Liam Wiltshire 2018년 1월 9일
Stephen you are bang on the money there, i couldn't get your original answer to work and unstead used Torstens reply without the y and came to the answer you now have above.
Thank you both very much for you input.
I had already tried using a function handle yesterday when i became stuck, but didn't put t in brackets after the @, so wrote it off.
All sorted now, thank you

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

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by