Hi all,
I have two vectors x and y, and I need to add a logarithmic best-fit line to the graph. This is a pretty easy feature to add on excel, but I am having trouble doing it in Matlab. Could someone please write some script using the two vectors on how to accomplish this? (Also, please no links. I tried to follow other Mathworks answers, but I still am not understanding this. Thanks!
Below is what the best fit line looks like on Excel (for reference to what I am asking)

 채택된 답변

Walter Roberson
Walter Roberson 2020년 12월 10일

1 개 추천

No. You have negative y data, and logarithmic fit of that would go complex valued.
If you only want the x to be logarithmic, then either use semilogx() or else plot in your normal way and the set the XScale property of the axes to 'log'

댓글 수: 3

Vladimir Sovkov
Vladimir Sovkov 2020년 12월 10일
편집: Vladimir Sovkov 2020년 12월 10일
In the graph, the experimental points do not contain negative or zero values in the x-axis, which logariths are real values. Besides, the logarithmic fit is not obligatory the pure logarithm, it can contain intercepts in both x and y, making it possible to work with zero and negative values within the real-type arithmetics.
Walter Roberson
Walter Roberson 2020년 12월 10일
When I search around, I do not find the possibility of there being a linear shift in anything called a "logarithmic fit". I only find that the log space might have a linear shift -- which corresponds to a multiplicative constant in linear space.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

질문:

2020년 12월 10일

댓글:

2020년 12월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by