필터 지우기
필터 지우기

How to enter an ln equation in a bisect function?

조회 수: 4 (최근 30일)
Bella
Bella 2016년 5월 26일
편집: John D'Errico 2016년 5월 26일
I am trying to find the real root of ln(x^2) = 0.7 using the bisection method but whenever i try to name the function with this equation it says that there is unbalanced parentheses.
func=@ln(x^2) = 0.7

채택된 답변

John D'Errico
John D'Errico 2016년 5월 26일
편집: John D'Errico 2016년 5월 26일
But that is not how you define a function. READ THE HELP! Look at the examples.
func = @(x) log(x.^2) - 0.7;
- x is the independent variable.
- log is the natural log function, so base e. While ln is used by some for that purpose, MATLAB uses log. log10 is log to the bas 10.
- Note the use of .^ for the square operation. This is a vectorized version, so the function will apply to any vector or array of elements.
- I subtracted 0.7, so you will be searching for a zero of func, thus where func(x) == 0.
Better yet would be to allow the user to provide the target, as a variable itself.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by