登录论坛

查看完整版本 : [MATLAB基础] 曲线拟合请教(在线等答疑)


feisha03
2011-10-18, 13:13
x=[0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0
10.5
11.0
11.5
12.0
12.5
13.0
13.5
14.0
14.5
15.0
15.5
16.0
16.5
17.0
17.5
18.0
18.5
19.0
19.5
20.0
20.5
21.0
21.5
22.0
22.5
23.0
23.5
24.0
24.5
25.0
25.5
26.0
26.5
27.0
27.5
28.0
28.5
29.0
29.5
30.0
30.5
31.0
31.5 ];y=[13.59
13.20
13.55
13.34
13.74
14.66
15.79
18.37
19.84
19.12
18.39
18.21
18.86
21.35
20.08
21.78
22.90
23.13
24.57
27.87
30.64
29.94
32.55
32.44
30.15
32.53
33.07
35.16
39.95
38.71
43.04
43.33
43.64
44.19
43.69
43.94
45.43
46.65
47.86
47.35
44.80
43.94
39.87
38.20
36.01
36.00
35.00
35.28
35.50
34.56
35.23
33.49
30.12
28.12
25.76
23.74
22.03
17.71
11.17
9.54
8.52
8.65
6.50
4.23 ];
k0=[0.01,0.01];
xyfit=inline('k(1)*(1.131740659712000e+008)*(x-34)^2*(x+k(2))^4','k','x');
[x,resid]=lsqcurvefit(xyfit,k0,x,y)

结果出现:
??? Error using ==> inlineeval at 15
Error in inline expression ==> k(1)*(1.131740659712000e+008)*(x-34)^2*(x+k(2))^4
Inputs must be a scalar and a square matrix.

Error in ==> inline.feval at 36
INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);

Error in ==> lsqcurvefit at 209
initVals.F = feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:});

Caused by:
Failure in initial user-supplied objective function evaluation. LSQCURVEFIT cannot continue.

请教下 怎么调整才可以得出参数k(1),K(2)