필터 지우기
필터 지우기

power law fit to find exponent

조회 수: 4 (최근 30일)
Bhowmik.U
Bhowmik.U 2020년 2월 17일
답변: Star Strider 2020년 2월 18일
I have a data in column matrix x and y
I need a power law fit say y=x^m
I require to plot scatter of y versus x and plot a power law fit on top of it ; and find m and display on graph.
any help will be appreciated!
  댓글 수: 4
Star Strider
Star Strider 2020년 2월 17일
If you want to linearise this equation:
y=x^m
take the logs of both sides. (There are much better ways to do this, however that will get you close enough.)
Bhowmik.U
Bhowmik.U 2020년 2월 18일
Sir, this wasnt a "homework"...was a question my junior asked me and I wanted to help him..nuthn else.
And yes Sir. I need to find out the "m" in y=x^m; I know y and x....Linearization isnt quite my aim...I want to what power of x do y vary!

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

답변 (1개)

Star Strider
Star Strider 2020년 2월 18일
I would do this (no Toolboxes required):
x = linspace(0, 5, 50); % Create Data
y = x.^pi + randn(size(x))*10; % Create Data
fcn = @(b,x) b(1).*x.^b(2) + b(3); % Objective Function
B = fminsearch(@(b) norm(y - fcn(b,x)), rand(3,1)*2) % Estimate Parameters
figure
plot(x, y, '.')
hold on
plot(x, fcn(B,x), '-r')
hold off
grid
Here, ‘m’ is ‘B(2)’.
Taking the logs of both sides will only work if both ‘x’ nor ‘y’ are >=0.

카테고리

Help CenterFile Exchange에서 Time Series Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by