24小时热门版块排行榜    

CyRhmU.jpeg
查看: 465  |  回复: 0
【悬赏金币】回答本帖问题,作者月璎珞将赠送您 300 个金币

月璎珞

至尊木虫 (职业作家)

[求助] 求带参数约束条件的数据拟合C语言程序

已知两列数据:X=[x1, x2, ……, xn],Y=[y1, y2, ……, yn];
拟合函数y=a*x^b+c拟合,其中a, b, c是拟合参数,且参数b必须满足约束条件:b∈[m, n].
我能用matlab实现,但现在需要不安装matlab,用C语言运行,跪求大神帮忙!

附matlab算例:
x=[332   414   507   653   739   888    1060    1268   1607   1920   2438    2886    3485];
y=[4.7   5.1   5.5    6    6.3    6.7    7.1    7.5     8      8.4    8.8     9.1     9.4]-4.7;
x=x';    % transfer Row matrix to Column matrix;
y=y';
p1=fittype('a*x^b+c','dependent',{'y'},'independent',{'x'},'coefficients',{'a', 'b', 'c'});  %  Fitting function
opts = fitoptions( 'Method', 'NonLinearLeastSquares' );
opts.Lower = [0  0.3 -20];
opts.StartPoint = [1, 0.4,-0.25];
opts.Upper = [200 0.49  0];
f1=fit(x,y,p1,opts);
res1=[coeffvalues(f1)]

不用安装matlab软件,怎么把上面的程序用C语言实现?
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 月璎珞 的主题更新
不应助 确定回帖应助 (注意:应助才可能被奖励,但不允许灌水,必须填写15个字符以上)
信息提示
请填处理意见