数学建模社区-数学中国
标题: 一个非线性曲线拟合问题的请教 [打印本页]
作者: legan 时间: 2009-8-26 15:40
标题: 一个非线性曲线拟合问题的请教
我们的问题是想用非线性最小二乘拟合出人口增长模型中Logistic的函数
: b4 u4 l1 g/ ]' dx(t)=xm/(1+(xm/x0-1)*exp(-rt))求出环境允许的最大值xm和增长率r;* Z1 t+ L0 D( O# B: B
我们用的matlab中的lsqcurvefit和lsqnonlin函数出现了问题,我们的函数如下:) V7 N8 t0 i2 l: U5 Q# Q
一、用lsqcurvefit函数求解, @8 d( `4 O- i. z8 I; h/ K. }# P3 L
%定义flogistic1函数并保存/ |$ x! X! F+ w# k' ?
function f=flogistic1(x,tdata)
f=x(1)/(1+(x(1)/243-1)*exp(-x(2)*t));
%主程序
/ ~) J# ^1 n( h. Lydata=[243
& U6 u1 F, I! P# d O$ `+ S t289 324 372 393 417 435 549 1086
; m; n! c2 |- A9 D: Q! `. I; `1263];
x=lsqcurvefit('flogistic1',x0,tdata,ydata)
??? Error using ==> optim\private\lsqncommon
User supplied function ==> flogistic1
failed with the following error:
Matrix dimensions must agree.
Error in ==> lsqcurvefit at 165
[x,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...
%定义flogistic2函数并保存
; }2 }% e- {9 W1 W1 Dydata=[243
* N( s+ V. L j/ }289 324 372 393 417 435 549 1086 1263];
f=ydata-x(1)/(1+(x(1)/243-1)*exp(-x(2)*tdata))
%主程序5 k# O2 ^# |+ T; q, g2 B* q
x=lsqnonlin('flogistic2',x0)
??? Error using ==> optim\private\lsqncommon
User supplied function ==> flogistic2
failed with the following error:
Matrix dimensions must agree.
Error in ==> lsqnonlin at 163
[x,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...
作者: legan 时间: 2009-8-26 15:40
希望好心人能帮我们解决下,感激不尽
作者: 东方明珠-WDZYQ 时间: 2009-8-26 16:46
查看MATLAB的help啊
作者: jd_lim 时间: 2009-8-29 00:13
可以用nlinfit方法直接模拟试试+ l1 d5 s6 L, B' @- e2 i4 N9 u) Z4 l
非线性回归分析
& D1 v8 U4 T, v/ N( G; f# S前提是把数据整理好# a+ t" ~# }' c
[beta,r,j]=nlinfit(x,y,'function')
# P$ o$ {- z5 e3 C" enlintool(x,y,'function',置信区间)
作者: handsome8848 时间: 2009-8-30 19:33
拟合?求最大值?LZ到底要表达什么意思。。。
1 a( ]8 ~7 Z# u% y1 p拟合还能求最大值?
作者: 杨帆 时间: 2009-8-30 20:04
谢谢楼主分享 。。。。
作者: 杨帆 时间: 2009-8-30 20:16
谢谢楼主分享 。。。。
作者: xieedemzitou 时间: 2009-9-3 12:52
4L有道理。。
作者: alair009 时间: 2012-1-26 11:32
恩,参考一下。。88450640562953597917111575064111625743336822603965473801748718741200358398380672
欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) |
Powered by Discuz! X2.5 |