MATLAB 自定义函数拟合问题·!nlinfit函数我弄不明白了!求助各位大神~!帮帮忙~ 80
v=a(5)*425*(0.9/425)^1.6*x.^1.6;A3=1-(1/(a(3)*425))^(1/a(2))*x.^(1/a(4));yy=(1./v).*l...
v=a(5)*425*(0.9/425)^1.6*x.^1.6;
A3=1-(1/(a(3)*425))^(1/a(2))*x.^(1/a(4));
yy=(1./v).*log10(A3./(a(1)+a(2)*v)+1);
ft=inline('yy','a','x1');
a=nlinfit(x1,y1,ft,[0 0 0 0 0]);
yy是我的拟合函数,由于比较复杂,里面部分以A3和v来代替,yy是整体的函数,。想对这个yy中的a(1)至a(5)进行拟合,但是运行之后总是出现
??? Index exceeds matrix dimensions.
各位能帮我纠正下哪的问题吗?我MATLAB学得不是很懂。如果能改过来更好了~!
x1:[0.299401198
0.479041916
0.778443114
0.898203593
0.934131737
1.089820359
1.221556886
1.293413174
1.401197605
1.568862275
1.640718563
1.988023952
2.191616766
2.359281437
2.550898204
2.634730539
3.137724551
3.221556886
3.329341317
3.473053892
]
y1:[336.9565217
336.9565217
337.9227053
337.9227053
336.9565217
298.3091787
301.2077295
300.2415459
300.2415459
300.2415459
300.2415459
269.3236715
269.3236715
265.4589372
270.2898551
270.2898551
234.5410628
233.5748792
232.6086957
232.6086957
] 展开
A3=1-(1/(a(3)*425))^(1/a(2))*x.^(1/a(4));
yy=(1./v).*log10(A3./(a(1)+a(2)*v)+1);
ft=inline('yy','a','x1');
a=nlinfit(x1,y1,ft,[0 0 0 0 0]);
yy是我的拟合函数,由于比较复杂,里面部分以A3和v来代替,yy是整体的函数,。想对这个yy中的a(1)至a(5)进行拟合,但是运行之后总是出现
??? Index exceeds matrix dimensions.
各位能帮我纠正下哪的问题吗?我MATLAB学得不是很懂。如果能改过来更好了~!
x1:[0.299401198
0.479041916
0.778443114
0.898203593
0.934131737
1.089820359
1.221556886
1.293413174
1.401197605
1.568862275
1.640718563
1.988023952
2.191616766
2.359281437
2.550898204
2.634730539
3.137724551
3.221556886
3.329341317
3.473053892
]
y1:[336.9565217
336.9565217
337.9227053
337.9227053
336.9565217
298.3091787
301.2077295
300.2415459
300.2415459
300.2415459
300.2415459
269.3236715
269.3236715
265.4589372
270.2898551
270.2898551
234.5410628
233.5748792
232.6086957
232.6086957
] 展开
1个回答
展开全部
function a=main()
x1=[0.299401198
0.479041916
0.778443114
0.898203593
0.934131737
1.089820359
1.221556886
1.293413174
1.401197605
1.568862275
1.640718563
1.988023952
2.191616766
2.359281437
2.550898204
2.634730539
3.137724551
3.221556886
3.329341317
3.473053892
];
y1=[336.9565217
336.9565217
337.9227053
337.9227053
336.9565217
298.3091787
301.2077295
300.2415459
300.2415459
300.2415459
300.2415459
269.3236715
269.3236715
265.4589372
270.2898551
270.2898551
234.5410628
233.5748792
232.6086957
232.6086957
];
% v=a(5)*425*(0.9/425)^1.6*x.^1.6;
% A3=1-(1/(a(3)*425))^(1/a(2))*x.^(1/a(4));
% yy=(1./v).*log10(A3./(a(1)+a(2)*v)+1);
% ft=inline('yy','a','x1');
a=nlinfit(x1,y1,@mymodel,ones(1,5));
end
function y= mymodel(a,x)
y = (1./(a(5)*425*(0.9/425)^1.6*x.^1.6)).*...
log10((1-(1/(a(3)*425))^(1/a(2))*x.^(1/a(4)))./(a(1)...
+a(2)*(a(5)*425*(0.9/425)^1.6*x.^1.6))+1);
end
x1=[0.299401198
0.479041916
0.778443114
0.898203593
0.934131737
1.089820359
1.221556886
1.293413174
1.401197605
1.568862275
1.640718563
1.988023952
2.191616766
2.359281437
2.550898204
2.634730539
3.137724551
3.221556886
3.329341317
3.473053892
];
y1=[336.9565217
336.9565217
337.9227053
337.9227053
336.9565217
298.3091787
301.2077295
300.2415459
300.2415459
300.2415459
300.2415459
269.3236715
269.3236715
265.4589372
270.2898551
270.2898551
234.5410628
233.5748792
232.6086957
232.6086957
];
% v=a(5)*425*(0.9/425)^1.6*x.^1.6;
% A3=1-(1/(a(3)*425))^(1/a(2))*x.^(1/a(4));
% yy=(1./v).*log10(A3./(a(1)+a(2)*v)+1);
% ft=inline('yy','a','x1');
a=nlinfit(x1,y1,@mymodel,ones(1,5));
end
function y= mymodel(a,x)
y = (1./(a(5)*425*(0.9/425)^1.6*x.^1.6)).*...
log10((1-(1/(a(3)*425))^(1/a(2))*x.^(1/a(4)))./(a(1)...
+a(2)*(a(5)*425*(0.9/425)^1.6*x.^1.6))+1);
end
追问
能留Q吗?有些细节想再请教
追答
404158021
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询