legan 发表于 2009-8-26 15:40

一个非线性曲线拟合问题的请教

我们的问题是想用非线性最小二乘拟合出人口增长模型中Logistic的函数
x(t)=xm/(1+(xm/x0-1)*exp(-rt))求出环境允许的最大值xm和增长率r;
我们用的matlab中的lsqcurvefit和lsqnonlin函数出现了问题,我们的函数如下:
一、用lsqcurvefit函数求解
%定义flogistic1函数并保存
function f=flogistic1(x,tdata)f=x(1)/(1+(x(1)/243-1)*exp(-x(2)*t));%主程序
tdata=2000:2009;ydata=[243
289 324 372 393 417 435 549 1086
1263];x0=;x=lsqcurvefit('flogistic1',x0,tdata,ydata)f=flogistic1(x,tdata)执行后出现的问题是:??? Error using ==> optim\private\lsqncommonUser supplied function ==> flogistic1failed with the following error: Error using ==> mrdivideMatrix dimensions must agree. Error in ==> lsqcurvefit at 165 = ...二、用lsqnonlin函数求解%定义flogistic2函数并保存
function f=flogistic2(x)tdata=2000:1:2009;ydata=[243
289 324 372 393 417 435 549 1086 1263];f=ydata-x(1)/(1+(x(1)/243-1)*exp(-x(2)*tdata))%主程序
x0=;x=lsqnonlin('flogistic2',x0)f=fogistic2(x)执行后出现的问题是??? Error using ==> optim\private\lsqncommonUser supplied function ==> flogistic2failed with the following error: Error using ==> mrdivideMatrix dimensions must agree. Error in ==> lsqnonlin at 163 = ...

legan 发表于 2009-8-26 15:40

希望好心人能帮我们解决下,感激不尽

东方明珠-WDZYQ 发表于 2009-8-26 16:46

查看MATLAB的help啊

jd_lim 发表于 2009-8-29 00:13

可以用nlinfit方法直接模拟试试
非线性回归分析
前提是把数据整理好
=nlinfit(x,y,'function')
nlintool(x,y,'function',置信区间)

handsome8848 发表于 2009-8-30 19:33

拟合?求最大值?LZ到底要表达什么意思。。。
拟合还能求最大值?

杨帆 发表于 2009-8-30 20:04

谢谢楼主分享 。。。。

杨帆 发表于 2009-8-30 20:16

谢谢楼主分享 。。。。

xieedemzitou 发表于 2009-9-3 12:52

4L有道理。。

alair009 发表于 2012-1-26 11:32

页: [1]
查看完整版本: 一个非线性曲线拟合问题的请教