Power Regression | PowerFit | MATLAB

Code:-

clc
clear all
close all;
format long;
x=[1 2 3 4 5 6];
y=[1 2.83 5.20 8 11.18 14.7];
plot(x,y,'o');
x1=x;
y=log10(y);
x=log10(x);
hold on;
a=[];
for i=1:length(x)
    a=[a ; x(i) 1];
end
c =a\y';
disp(c)
c(2)=10^(c(2));
hold on;
x=min(x1):0.01:max(x1);
y=c(2)*(x.^c(1));
plot(x,y,'g');
grid on;

No comments