Fminsearch Matlab(非线性回归) [英] Fminsearch Matlab (Non Linear Regression )

查看:122
本文介绍了Fminsearch Matlab(非线性回归)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以向我解释如何将非线性回归应用于此方程,然后使用matlab命令窗口找出K.

Can anyone explain to me how I can apply non linear regression to this equation t find out K using the matlab command window.

I = 10 ^ -9(exp(38.68V/k)-1). 公式的屏幕截图

I = 10^-9(exp(38.68V/k)-1). Screenshot of Equation

我的数据值如下:

Voltage := [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]:
Current:= [0, 0, 0, 0, 0, 0, 0, 0.07, 0.92, 12.02, 158.29]:

方程式的屏幕截图

[NEW]:现在我使用FminSearch作为替代,另一个错误消息出现了.

[NEW]: Now I used FminSearch as an alternative another and another error message appeared.

Matrix dimensions must agree.

Error in @(k)sum((I(:)-Imodel(V(:),k)).^2)

Error in fminsearch (line 189)
fv(:,1) = funfcn(x,varargin{:});

我使用了以下fminsearch代码:

I used this fminsearch code:

>> V = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0];
>> I = [0, 0, 0, 0, 0, 0, 0.07 ,0.92 ,12.02 ,158.29];
>> Imodel = @(V,k) 1E-9*(exp(38.68*V/k)-1);
>> k0 = 1;
>> kmodel = fminsearch(@(k) sum((I(:)-Imodel(V(:),k)).^2), k0)    
>> kmodel = fminsearch(@(k) sum((I(:)-Imodel(V(:),k)).^2), k0);

推荐答案

您想找到参数k,该参数将最小化指数模型的平方误差总和(BTW,这是电流/电压特性吗?)给定当前数据I和电压数据V作为向量:

You want to find the parameter k that will minimize the sum of squared error of your exponential model (BTW, is that a current/voltage characteristic?) given the current data I and voltage data V as vectors:

Imodel = @(V,k) 1E-9*(exp(38.68*V/k)-1);
k0     = 1;
kmodel = fminsearch(@(k) sum((I(:)-Imodel(V(:),k)).^2), k0);

plot(V(:), I(:), 'ok', V(:), Imodel(V(:),kmodel), '-r');

匿名函数计算平方误差的总和.搜索将使模型误差最小的参数k从值1开始;否则,从0开始.请将其更改为更合适的值(如果您对此有很好的猜测).

The anonymous function calculates the sum of squared error. The search for the parameter k that will minimize the model error starts with the value 1; please change it to a more appropriate value (if you have a good guess for it).

这篇关于Fminsearch Matlab(非线性回归)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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