使用MATLAB将Sigmoid拟合到我的数据 [英] Fit a sigmoid to my data using MATLAB

查看:1432
本文介绍了使用MATLAB将Sigmoid拟合到我的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多数据,我认为有可能将其拟合为S形(这种想法是基于我的视力,而不是数学公式).

I have a lot of data, and I think it is possible to fit it to a sigmoid (this thought based on my eye-sight, not a mathematical formula).

如何找到对数据具有最佳S形统计意义的具有统计意义的解释力的参数形式?

How can I find the parametric form with statistically significant explanatory power of the best sigmoid for my data?

谢谢!

推荐答案

您可以做的一件很棒的事情是在Matlab中使用曲线拟合"应用程序.您可以在APPS的数学,统计和优化"部分中找到它.

One great thing that you can do is to use the "Curve fitting" App in Matlab. you can find it in APPS, in "Math, statistics and optimization" section.

在那里,您可以选择x和y数据以及要适合它们的函数(可以输入自定义方程式,如Sigmoid).

over there you can choose your x and y data and the function that you want to fit over them (you can enter custom equations such as sigmoid).

然后,您可以在图上看到拟合结果,并且还显示了拟合参数.

Then you can see the fitting results on a plot, also, fitting parameters are shown.

如果您对结果感到满意,并且想要在代码中使用它们,只需在文件"选项卡下单击生成代码"即可. 您可以在我拍摄的此屏幕截图中查看详细信息.按下生成代码按钮后,matlab将创建一个函数,该函数将提供相同的结果.在这种情况下,我想做的就是复制所需的零件:

If you were satisfied with the results and you want to use them inside a code, simply hit the generate code under the File tab. you can see the details in this screenshot i took. after pressing the generate code button, matlab will create a fuction that will give the same result. what i like to do is just copy the parts i need in this case:

 enter code here
 [xData, yData] = prepareCurveData( x, y );

 % Set up fittype and options.
ft = fittype( 'a/(1+exp(-b*x))', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.StartPoint = [0.957166948242946 0.485375648722841];

% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );

如您所见,matlab添加了必要的详细信息,现在您可以使用fitresult访问拟合参数.例如-> fitresult.a

as you can see matlab adds the necessary details and now you can access fitting parameters using fitresult. for example-> fitresult.a

这篇关于使用MATLAB将Sigmoid拟合到我的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆