in curve fitting of linear sinusoidal function with polynomial of 4th degree, the error popping up is define b and x_l

1 view (last 30 days)
I am new to matlab. I would appreciate to sort this out of curve fitting algorithm of linear sinusoidal function with polynomial of 4th degree
m=input('enter order:');
n=input('enter number of data points:');
x=[1 2 3 4 5 6];
y=b(0)+b(1)*sin(x)+b(2)*sin(x).^2;
x_l_mat=[];
y_l_mat=[];
x_l_mat=[x_1_mat; x_1];
y_1_mat=[y_1_mat; y_l];
if (n<(m+1))
disp('regression is impossible');
else
for i=1:m+1
for j=1:i
k=i+j-2;
sum=0;
for l=1:n
sum=sum+(x_l).^k;
end
a_(i,j)=sum;
a_(j,i)=sum;
end
sum=0;
for l=1:n
sum=sum+y_l.x_l^(i-1);
end
a_(i,m+2)=sum;
end
end
  3 Comments

Sign in to comment.

Answers (0)

Categories

Find more on Linear and Nonlinear Regression in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!