What does this error mean? fminsearch error: "Assignment has more non-singleton rhs dimensions than non-singleton subscripts"
1 次查看(过去 30 天)
显示 更早的评论
I am trying to Optimize these set of equations to find vector c with i=1,2:
Bold variables are 3D Vectors.
Known Variables: R, o, u1, u2, l1, l2
My code works when I use fsolve but gives me an error for fminsearch
fun.m :
function F = fun(x1,R,o,u1,u2,l1,l2)
c=x1(1:3);
kq1=x1(4);
kq2=x1(5);
q1=x1(6:8);
q2=x1(9:11);
b=x1(12:14);
bnorm=x1(15:17);
kc=x1(18);
F(1:3) = o + kq1*(o-u1) - q1;
F(4:6) = o + kq2*(o-u2) - q2;
F(7) = norm(q1-c) - R;
F(8) = norm(q2-c) - R;
F(9) = (dot((o-q1),(q1-c))*norm(l1-q1)) - (dot((l1-q1),(q1-c))*norm(o-q1));
F(10) = (dot((o-q2),(q2-c))*norm(l2-q2)) - (dot((l2-q2),(q2-c))*norm(o-q2));
F(11:13) = (kc*bnorm)-(c-o);
F(14:16) = (b/norm(b))- bnorm;
F(17:19) = (cross(cross((l1-o),(u1-o)),cross((l2-o),(u2-o)))) - b;
end
script.m :
clear all; clc;
R = 7.8;
o=[0,0,0];
u1= [7.4390,7.1380,-0.0607];
u2=[6.5360,7.1380,-0.0607];
l1=[-83.7542,77.3087,-58.0508];
l2=[66.2458,74.8087,-51.0508];
x0 = ones(1,18);
[x fval]= fminsearch(@fun,x0,[],R,o,u1,u2,l1,l2);
OUTPUT:
%
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Nonlinear Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!