matlab求曲线拟合参数x=[0.25,0.5,0.75,1,1.5,2,2.5,3,3.5,4,4.5,5,6,7,8,9,10,11,12,13,14,15,16]y=[30,68,75,82,82,77,68,68,58,51,50,41,38,35,28,25,18,15,12,10,7,7,4]求A和B的值 请问该如何编写程序.
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/23 00:25:42
matlab求曲线拟合参数x=[0.25,0.5,0.75,1,1.5,2,2.5,3,3.5,4,4.5,5,6,7,8,9,10,11,12,13,14,15,16]y=[30,68,75,82,82,77,68,68,58,51,50,41,38,35,28,25,18,15,12,10,7,7,4]求A和B的值 请问该如何编写程序.
matlab求曲线拟合参数
x=[0.25,0.5,0.75,1,1.5,2,2.5,3,3.5,4,4.5,5,6,7,8,9,10,11,12,13,14,15,16]
y=[30,68,75,82,82,77,68,68,58,51,50,41,38,35,28,25,18,15,12,10,7,7,4]
求A和B的值 请问该如何编写程序.
matlab求曲线拟合参数x=[0.25,0.5,0.75,1,1.5,2,2.5,3,3.5,4,4.5,5,6,7,8,9,10,11,12,13,14,15,16]y=[30,68,75,82,82,77,68,68,58,51,50,41,38,35,28,25,18,15,12,10,7,7,4]求A和B的值 请问该如何编写程序.
需要用到非线性拟合函数,按你这个式子我试了下好像拟合不出结果,所以我把你的式子简化了一下,前面那一部分(35.72A/4333.3(B-A))其实也可以看做一个参数,就叫做C吧,自己建立一个m文件,我起名为shiyan1.m
function shiyan1
xdata = [0.25,0.5,0.75,1,1.5,2,2.5,3,3.5,4,4.5,5,6,7,8,9,10,11,12,13,14,15,16 ];
ydata = [ 30,68,75,82,82,77,68,68,58,51,50,41,38,35,28,25,18,15,12,10,7,7,4];
a0 = [ 1, 1, 1 ]; % 初始化参数
[ a, resnorm ] = lsqcurvefit( @subfun, a0, xdata, ydata )
% 绘制曲线
fy = subfun( a, xdata );
figure( 1 );
plot( xdata, ydata, 'r*' );
hold on;
plot( xdata, fy, 'b-' );
legend( '原始数据', '拟合数据' )
function y = subfun( a, x )
% y = ( 35.72 * a( 1 ) / ( 4333.3 * ( a( 2 ) - a( 1 ) ) ) ) *...
% ( exp( -a( 1 ) * x ) - exp( -a( 2 ) * x ) );
y = a( 3 ) * ( exp( -a( 1 ) * x ) - exp( -a( 2 ) * x ) );
你所要求得A B C就是代码里a的第一、第二数和第三个数