Approximation Report
Approximation Report
Lab 5:
Approximation
Edgar Abasov
Objective of current report is to perform approximation methods using Matlab software and language on a
few examples.
1) First example of wire coil represents dependence temperature and resistance where we should
compute values: temperature co-efficient of Resistance.
• Firstly, here performed converting given input data into working form.
• Following step is to compute equation roots using Matlab’s already predefined functions polyfit
and polyval. As it shown (Above and right graph) linearity of input data is obvious and
approximation regression line location is right.
• Also, we got roots: 0.2235 and 133.2177 which are temperature co-efficient of Resistance a and
b in equation at the task paper.
T = [-85.02,-33.36,-9.99,32.88,1000.00,218.00,356.58,444.50,630.50];
%disp(T);
% Resistance in ohms
p = polyfit(T,R,1);
disp(p)
plot(p)
T1 = T;
R1 = polyval(p,T1);
figure
plot(T,R,'o')
hold on
plot(T1,R1)
hold off
2) Second task is to count relative error from input data set. Also, implementation performed using
Matlab.
• Input data computed throught the equation (X'*X)*-1*X'*y;
• Relative error computed using classic approximation formula
Result are:
Source code for task2:
X = [1 0; 1 2.5;1 5.5; 1 8.5; 1 11];
disp(X);
n=5;
relative_error=zeros(n);
disp(y);
p = (X'*X)*-1*X'*y;
disp(p);
relative_error=[];
y1 = X*p;
sum = 0;
for i=1:n
relative_error(i)=(1-y1(i)/y(i))*100;
fprintf('% %',i,relative_error(i));
sum=sum+abs(relative_error(i));
end