LEDdata

scalefactor = 180/pi;
angle = angle/scalefactor;

n = 3;

F = ones(length(angle),n);
for k = 1:n
  F(:,k) = angle.^(2*(k-1));
end

[p,int_var,r,p_var] = LinearRegression1(F,intensity);
[p,sqrt(p_var)]       % display the estimated values for the parameters

al = ((0:1:90)')/scalefactor; % consider angles from 0 to 90 degree

Fnew = ones(length(al),n);
for k = 1:n
  Fnew(:,k) = al.^(2*(k-1));
end

Inew = Fnew*p;
plot(angle*scalefactor,intensity,'*',al*scalefactor,Inew)
