matlab nlinfit的问题
f=@(a,t)a(1).*exp(a(2).*(t-a(3)))t=[1790,1800,1810,1820,1830,1840,1850,1860,1870,1880...
f=@(a,t)a(1).*exp(a(2).*(t-a(3)))
t=[1790,1800,1810,1820,1830,1840,1850,1860,1870,1880,1890,1900,1910,1920,1930,1940,1950,1960,1970,1980,1990,2000]
y=[3.9,5.3,7.2,9.6,12.9,17.1,23.2,31.4,38.6,50.2,62.9,76.0,92.0,106.5,123.2,131.7,150.7,179.3,204.0,226.5,251.4,281.4]
k=nlinfit(t,y,f,k0)
k0=[3.9,1,1790]
sse=sum((y-f(a,t)).^2)
哪里错了??? 展开
t=[1790,1800,1810,1820,1830,1840,1850,1860,1870,1880,1890,1900,1910,1920,1930,1940,1950,1960,1970,1980,1990,2000]
y=[3.9,5.3,7.2,9.6,12.9,17.1,23.2,31.4,38.6,50.2,62.9,76.0,92.0,106.5,123.2,131.7,150.7,179.3,204.0,226.5,251.4,281.4]
k=nlinfit(t,y,f,k0)
k0=[3.9,1,1790]
sse=sum((y-f(a,t)).^2)
哪里错了??? 展开
展开全部
clear;clc
f=@(a,t)a(1).*exp(a(2).*(t-a(3)))
t=[1790,1800,1810,1820,1830,1840,1850,1860,1870,1880,1890,1900,1910,1920,1930,1940,1950,1960,1970,1980,1990,2000];
y=[3.9,5.3,7.2,9.6,12.9,17.1,23.2,31.4,38.6,50.2,62.9,76.0,92.0,106.5,123.2,131.7,150.7,179.3,204.0,226.5,251.4,281.4];
k0=[1,0.01,1000]; % 初值放在此行
k=nlinfit(t,y,f,k0)
plot(t,y,'*',t,f(k,t))
sse=sum((y-f(k,t)).^2) % 不是f(a,t)
追问
谢谢 请问 我的问题是不是应该要a=nlinfit~?还有你是怎么算k0的?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询