趋势线选项(excel)在matlab中

在Excel中,我记得能够select一个特定的趋势线,称为“权力”,根据文件:

“功率趋势线是一条曲线,最适合用于比较以特定速率增加的测量值的数据集,例如,以一秒为间隔的赛车加速度。 如果数据包含零或负值,则不能创buildpowershell趋势线。

我怎样才能在matlab中实现这个?

例如:

a = [15.5156,0.1995; 7.6003,0.2999; 9.4829,0.2592; 12.2185,0.2239; 23.4094,0.1811]; figure;scatter(a(:,1),a(:,2)) 

这是一个可行的解决scheme:

 a = [15.5156,0.1995; 7.6003,0.2999; 9.4829,0.2592; 12.2185,0.2239; 23.4094,0.1811]; x = a(:, 1); y = a(:, 2); n = 2; % order of the fitted polynomial trendline p = polyfit(x, y, n); m = 1000; % number of trendline points (the larger the smoother) xx = linspace(min(x), max(x), m); yy = polyval(p, xx); figure; hold on; scatter(a(:,1), a(:,2)); plot(xx, yy, 'r-'); 

你可以很容易地把趋势线计算器代码放到一个单独的函数中。

我把你的数据绘制在excel上,并用下面的公式添加一个“power”趋势线:

 y = 0.7188 x^{-0.4513} 

这当然是一种权力法。

在Matlab中的模拟是执行线性适合您的数据的日志对数转换(这解释了强大的趋势线应用程序在Excel中强加的限制):

 x = a(:, 1); y = a(:, 2); p = polyfit(log(x), log(y), 1); % <-- linear fit 

这使

 p = -0.4513 -0.3302 

覆盖趋势线就像@kol,但是与权力法则:

 xx = linspace(min(x), max(x), 100); yy = exp(p(2))*xx.^p(1); figure; hold on; scatter(x, y); plot(xx, yy, 'r-'); 

对于某些值<0的xxyy ,在尝试此操作之前需要进行数据移位。