本人菜鸟一个,论文要用到优化设计,写了一个程序。运行错误提示:??? Error using ==> svd2 x9 E' a1 b4 l0 O
Input to SVD must not contain NaN or Inf.求大神们帮帮忙。很着急!!: [4 B+ `( P! [/ a' M5 M
clc;7 T! r% I5 z/ C+ {
clear all;( R' t, s v: l- `
global L1 L54 ]: D' n [0 d
L1=3000;6 x& n5 z0 B- R. q E, a
L5=1800; ' Q$ ?8 ^: o/ U$ E! Ax0=[780;2000;800;800;pi/12];* | r5 u3 b; K4 y) ]
options=optimset('largeScale','off','TolFun',1e-12); & G7 Z+ d6 e$ y9 I[x,fval,exitflag,output]=fmincon(@link_objfun1,x0,[],[],[],[],[],[],@link_confun1,options);6 O4 f8 h/ W, o' d z/ y$ B
# I. f# R. s W3 f3 `* G* `1 Y
+ n- k% M6 B6 b+ O%目标函数 9 l2 n$ d; M. s" W; `8 Pfunction f=link_objfun1(x) # v! _4 h! X6 t% l. s( Bglobal L1 L5 5 G( f" j. k' I8 d$ ~: t) Q# tf=0;1 I6 W4 G( K. K+ J4 J2 \
snti0=0;" N L$ X& P- G0 k
for i=0:10 5 r7 }$ _- o# T+ i' gsnti=snti0+pi/6*i/10; 2 F+ b3 G3 e O8 a" ~
bati=acos((L1-x(1)*sin(snti+x(5)))/(L1^2+x(1)^2-2*L1*x(1)*sin(snti+x(5)))^1/2).... v' [+ e' a( o! @+ `
+acos((L1^2+x(1)^2+x(3)^2-x(2)^2-2*L1*x(1)*sin(snti+x(5)))/2*x(3)*(L1^2+x(1)^2-2*L1*x(1)*sin(snti+x(5)))^1/2)... # R6 g) E* w, r2 D+ n+ @ +acos(x(4)/x(3)); / N3 @3 N+ w# }f=f+(L1*cossnti+L5*cos(snti+bati)-L1)^2; & d, q) o9 P7 ^! H& M; f" Vend % @( c' j3 ?" e: u- I( o( v2 Z- ]2 ]2 ?7 K: {, e j6 @' M$ @4 Z% v7 [
%约束函数 ^0 ~7 ]9 e }' _+ b& ?/ T2 f4 k
function [c ceq]=link_confun1(x)9 a% ^5 g0 i v9 \; a6 E- c& ^
global L13 S4 ?& C+ }' ?& ]2 s: F( D* ^
snti0=0; ! [2 d" A0 I) C7 `3 z7 L* Hbati0=acos((L1-x(1)*sin(snti0+x(5)))/(L1^2+x(1)^2-2*L1*x(1)*sin(snti0+x(5)))^1/2)...0 s* i7 Y9 u. E1 c2 \% s
+acos((L1^2+x(1)^2+x(3)^2-x(2)^2-2*L1*x(1)*sin(snti0+x(5)))/2*x(3)*(L1^2+x(1)^2-2*L1*x(1)*sin(snti0+x(5)))^1/2)... / L% _# J s7 d7 F +acos(x(4)/x(3));; x0 k. |8 _6 \* U, W3 S7 R+ q$ o
c=[-x(1) 6 d5 z6 E' b5 W -x(2)* t' f: I0 ^( H, }! o; f
-x(3) 5 o. }, r2 Z7 b# x, s -x(4) 4 S Y$ c2 R3 ~% [/ k x(1)-L1" v6 V( L+ d/ U6 K, v9 l
x(1)-x(2) 8 X0 [# q& J1 u& \& H x(1)-x(3)# g) C3 ^/ C. n& c7 x( c7 K
x(1)+x(2)-x(3)-L19 R4 R! p g/ E9 K) }* C: O* C
L1-x(2)-x(3)-x(1) , P2 k, U8 P( i" q) c1 K- M4 w# R x(3)-x(1)-x(2)-L1];8 N5 _, e# E. \7 O: L. ~
ceq=bati0-pi/2;