Lab 10

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

1.

clc;
clearall;
closeall;
x=[5506006507007508008509009501000];
y=[41.218.628.623.921.861.451.110.720.510.02];
coeffs=polyfit(x,y,1);
coeffs2=polyfit(x,y,2);
coeffs3=polyfit(x,y,3);
newX=550:5:1000;
newY=polyval(coeffs,newX);
newY2=polyval(coeffs2,newX);
newY3=polyval(coeffs3,newX);
plot(x,y,'o',newX,newY,'b',newX,newY2,'r',newX,newY3,'g.');
xlabel('xaxis');
ylabel('yaxis');
title('Regression');
legend('Orignaldata','2ndOrderregression','3rdOrderregression');

2.
clc;
clearall;
closeall;
x=0:pi/10:pi;
y=[54.754.042.941.5401.542.944.044.755];
holdon;
plot(x,y,'o');
new_x=0:0.05:pi;
new_y=interp1(x,y,new_x,'spline');
plot(new_x,new_y,'b');
holdoff;
xlabel('xaxis');
ylabel('yaxis');
title('InterpolatedData');
legend('OriginalData','SplineData');

3.
clc;
clearall;
closeall;
a=30;
b=100;
x=rand(1,1000);
grades=(ba)*x+a;
grades=round(grades);
hist(grades);
title('Grades');
xlabel('xaxis');
ylabel('yaxis');

4.
clear;
clc;
A=[423;134;312];
B=[1;7;5];
C=A\B;
fprintf('Thevalueofxis%d\n',C(1));
fprintf('Thevalueofyis%d\n',C(2));
fprintf('Thevalueofzis%d\n',C(3));

You might also like