帮忙拟合个数据matlabx=[36 39 42 45 48 52 55 59 63 67 71 75 80 84 89

帮忙拟合个数据matlab
x=[36 39 42 45 48 52 55 59 63 67 71 75 80 84 89 93 87 92 99 105 110 115 120 124 130 134 138 142 146 149 153 155 158 160 162 163 164 165 165 165 164 163 162 160 158 155 152 148 144 140 135 130 125 120 114 108 103 96 90 85 77 73 67 62 43 36 29 22 16 10 3 -2 -2 -14 -19 -25 -31 -37 -42 -48 -54 -59 -65 -70 -76 -81 -87 -92 -97 -103 -108 -113 -118 -115 -119 -125 -130 -135 -139 -144]
y=[-161 -160 -160 -159 -158 -157 -156 -155 -154 -152 -151 -149 -146 -144 -142 -139 -129 -126 -122 -118 -114 -110 -105 -100 -94 -88 -82 -76 -69 -62 -54 -47 -39 -31 -23 -14 -6 3 12 20 29 38 47 56 64 73 81 90 98 106 113 121 128 134 141 147 152 158 163 167 172 175 179 182 179 181 183 185 186 187 188 188 189 189 188 188 188 187 186 185 184 183 181 179 177 175 172 170 168 164 161 158 155 145 142 138 134 129 125 120 ]
acid8399 1年前 已收到1个回答 举报

lissibo 幼苗

共回答了31个问题采纳率:83.9% 举报

x=[36 39 42 45 48 52 55 59 63 67 71 75 80 84 89 93 87 92 99 105 110 115 120 124 130 134 138 142 146 149 153 155 158 160 162 163 164 165 165 165 164 163 162 160 158 155 152 148 144 140 135 130 125 120 114 108 103 96 90 85 77 73 67 62 43 36 29 22 16 10 3 -2 -2 -14 -19 -25 -31 -37 -42 -48 -54 -59 -65 -70 -76 -81 -87 -92 -97 -103 -108 -113 -118 -115 -119 -125 -130 -135 -139 -144];
y=[-161 -160 -160 -159 -158 -157 -156 -155 -154 -152 -151 -149 -146 -144 -142 -139 -129 -126 -122 -118 -114 -110 -105 -100 -94 -88 -82 -76 -69 -62 -54 -47 -39 -31 -23 -14 -6 3 12 20 29 38 47 56 64 73 81 90 98 106 113 121 128 134 141 147 152 158 163 167 172 175 179 182 179 181 183 185 186 187 188 188 189 189 188 188 188 187 186 185 184 183 181 179 177 175 172 170 168 164 161 158 155 145 142 138 134 129 125 120 ];
[x0,y0,R0,a]=circfit(x,y);
alpha=0:pi/20:2*pi;
xx=R0*cos(alpha)+x0;
yy=R0*sin(alpha)+y0;
plot(x,y,'b+',xx,yy,'r-');
mystring=['x0=',num2str(x0),',y0=',num2str(y0),',R=',num2str(R0)];
text(x0,y0,mystring);
axis equal
%其中调用的circfit函数程序如下:
function [xc,yc,R,a] = circfit(x,y)
%CIRCFIT Fits a circle in x,y plane
%
% [XC, YC, R, A] = CIRCFIT(X,Y)
% Result is center point (yc,xc) and radius R.A is an
% optional output describing the circle’s equation:
%
% x^2+y^2+a(1)*x+a(2)*y+a(3)=0
% by Bucher izhak 25/oct/1991
n=length(x); xx=x.*x; yy=y.*y; xy=x.*y;
A=[sum(x) sum(y) n;sum(xy) sum(yy)...
sum(y);sum(xx) sum(xy) sum(x)];
B=[-sum(xx+yy) ; -sum(xx.*y+yy.*y) ; -sum(xx.*x+xy.*y)];
a=AB;
xc = -.5*a(1);
yc = -.5*a(2);
R = sqrt((a(1)^2+a(2)^2)/4-a(3));
我是用圆拟合的

1年前

8
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 17 q. 0.148 s. - webmaster@yulucn.com