注册 登录
编程论坛 Matlab

如何用matlab解这个非线性最小二乘问题

andyjiangming 发布于 2006-06-02 00:45, 1936 次点击

f=i-(x(1)+x(2)*lg(t2))/(t1+x(3))^x(4)

i=[2.04,1.61,1.34,1.21,0.98,0.79,0.65;...

2.39,1.88,1.59,1.44,1.15,0.95,0.80;...

2.53,2.03,1.74,1.56,1.26,1.04,0.88;...

2.75,2.18,1.86,1.72,1.37,1.12,0.96;...

3.04,2.42,2.06,1.90,1.53,1.29,1.09]

t1=[5,10,15,20,30,45,60]

t2=[1,2,3,5,10]

我用matlab的lsqnonlin求解,但总是报错,说什么 matrix must be square,不知哪位高手可以帮帮小弟,最好附上程序,万分感谢!

4 回复
#2
莫默2006-06-29 14:10
t1 与t2的维数不同啊
#3
ydgsl2006-09-20 21:11

该数据的结果应为:
x=[7.91765722, 1.78620121, 5.66510033, .576840487];
请运行下列程序:
clear,clc
t1=[5 5 5 5 5 10 10 10 10 10 15 15 15 15 15 20 20 20 20 20 30 30 30 30 30 45 45 45 45 45 60 60 60 60 60]';
t2=[1 2 3 5 10 1 2 3 5 10 1 2 3 5 10 1 2 3 5 10 1 2 3 5 10 1 2 3 5 10 1 2 3 5 10]';
x=[7.91765722, 1.78620121, 5.66510033, .576840487];
I=(x(1)+x(2)*log(t2))./(t1+x(3)).^x(4);
scatter3(t1,t2,I)
stem3(t1,t2,I,'filled')
str=num2str([1:35]');
hold on
text(t1,t2,I,str,'fontsize',15)
[t11,t22]=meshgrid(min(t1):.5:max(t1),min(t2):1:max(t2));
I1=(x(1)+x(2)*log(t22))./(t11+x(3)).^x(4);
surf(t11,t22,I1);
shading interp
axis tight
alpha(.8)

#4
ydgsl2006-09-20 21:18

刚才的程序有错:
请运行下列程序:
clear,clc
t1=[5 5 5 5 5 10 10 10 10 10 15 15 15 15 15 20 20 20 20 20 30 30 30 30 30 45 45 45 45 45 60 60 60 60 60]';
t2=[1 2 3 5 10 1 2 3 5 10 1 2 3 5 10 1 2 3 5 10 1 2 3 5 10 1 2 3 5 10 1 2 3 5 10]';
I=[2.04 2.39 2.53 2.75 3.04 1.61 1.88 2.03 2.18 2.42 1.34 1.59 1.74 1.86 2.06 1.21 1.44 1.56 1.72 1.9 0.98 1.15 1.26 1.37 1.53 0.79 0.95 1.04 1.12 1.29 0.65 0.8 0.88 0.96 1.09]'
x=[7.91765722, 1.78620121, 5.66510033, .576840487];
scatter3(t1,t2,I)
stem3(t1,t2,I,'filled')
str=num2str([1:35]');
hold on
text(t1,t2,I,str,'fontsize',15)
[t11,t22]=meshgrid(min(t1):.5:max(t1),min(t2):1:max(t2));
I1=(x(1)+x(2)*log(t22))./(t11+x(3)).^x(4);
surf(t11,t22,I1);
shading interp
axis tight
alpha(.8)

#5
hitzhang2006-12-09 18:50
andyjiangming的问题像是一个矩阵优化问题,是求矩阵函数f的最小值,假设是这样,想请教ydgsl又如何解决呢
1