LEDdata;   % read the data 

figure(1);
plot(angle,intensity,'*');

n = 6; % ploynomial of degree n-1

F = ones(length(angle),n);
for k = 1:n
  F(:,k) = angle.^(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)'; % consider angles from 0 to 90 degree
Fnew = ones(length(al),n);
for k = 1:n
  Fnew(:,k) = al.^(k-1);
end

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

