简体   繁体   中英

MATLAB: power function curve fitting

I would like to know the MATLAB code form of the power polynomial y = x m .
I require the numerical value of m by fitting this curve to a set of data. My initial program is as follows:

load A   
N = A(:, 1);
t = A(:, 2);    
p = polyfit(log(N), log(t), 1);    
f = (p, t);    
plot(t, N, '-', t, f, '-');

My only doubt is the above polyfit function used for curve fitting is for the equation y = bx m which is not fitting my data set, where I require b = 1.

Third parameter of polyfit is degree of polynomial, m in your case.

You can pass parameter larger than m to polyfit . Then, if your assumption about model is correct p[m + 1] will be the largest component of p (and close to 1), while others should be close to zero.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM