最小二乘法2階擬合數據

clc
close allit

fd1 =fopen('.\x.txt'); 
x=textscan(fd1,'%.2f%*[^\n]');
fclose(fd1);
fd2 = fopen('.\y.txt');
y=textscan(fd2,'%.2f%*[^\n]');
fclose(fd2);grid

p = polyfit(x{1},y{1},2);
pp= polyval(p,x{1});
x1 = x{1}(10)+2*2;%-143.0;
y1 = polyval(p,x1);ab

plot(x{1},y{1},'*b',x{1},pp,'Or');
hold on
plot(x1,y1,'xr');

z1 = sqrt(x1*x1+y1*y1); d = y1/x1; j =270 -  atan(d)*180/3.14159265;  v = abs(-y1-604)/2; grid on  

相關文章
相關標籤/搜索