The problem in fminsearch function error
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a problem in this code.
What I try to do is to get a minmum value of the 'equation'
But when I run the m.file, I got a message like this; Please help me to solve this problem.
Here are the 'error message' and 'code' that I made.
Thank you
-----------------------------------------------------------------------------
??? The following error occurred converting from sym to double:
Error using ==> mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.
Error in ==> fminsearch at 191
fv(:,1) = funfcn(x,varargin{:});
Error in ==> main_variable_change at 65
[x,fval] = fminsearch(equation, x0)
----------------------------------------------------------------------------
clc; clear;
x = sym(zeros(6,1));
for i=1:1:6
x(i) = sym(sprintf('x%d',i));
end
P = zeros(2,2);
P = [x(1), 1-x(1); 0, 1];
Q= zeros(2,3);
Q = [x(2), 1-x(2), 0; 0, x(3), 1-x(3)];
N=2;
pi_01 = 1;
pi_02 = 0;
Tr = [0.13, 0.18, 0.31, 0.49, 0.53, 0.53, 0.55, 0.8, 1.44, 1.71, 1.82, 1.9, 1.99, 2.12, 2.15, 2.34, 2.54, 3.05, 3.36, 4.61];
pi(1,1,1) = (pi_01 * P(1,1) * Q(1,1) + pi_02 * P(2,1) * Q(1,1)) / (pi_01 * P(1,1) * Q(1,1) + pi_01 * P(1,2) * Q(2,1) + pi_02 * P(2,1) * Q(1,1) + pi_02 * P(2,2) * Q(2,1)) ;
pi(1,1,2) = (pi_01 * P(1,1) * Q(1,2) + pi_02 * P(2,1) * Q(1,2)) / (pi_01 * P(1,1) * Q(1,2) + pi_01 * P(1,2) * Q(2,2) + pi_02 * P(2,1) * Q(1,2) + pi_02 * P(2,2) * Q(2,2)) ;
pi(1,1,3) = (pi_01 * P(1,1) * Q(1,3) + pi_02 * P(2,1) * Q(1,3)) / (pi_01 * P(1,1) * Q(1,3) + pi_01 * P(1,2) * Q(2,3) + pi_02 * P(2,1) * Q(1,3) + pi_02 * P(2,2) * Q(2,3)) ;
pi(1,2,1) = (pi_01 * P(1,2) * Q(2,1) + pi_02 * P(2,2) * Q(2,1)) / (pi_01 * P(1,1) * Q(1,1) + pi_01 * P(1,2) * Q(2,1) + pi_02 * P(2,1) * Q(1,1) + pi_02 * P(2,2) * Q(2,1)) ;
pi(1,2,2) = (pi_01 * P(1,2) * Q(2,2) + pi_02 * P(2,2) * Q(2,2)) / (pi_01 * P(1,1) * Q(1,2) + pi_01 * P(1,2) * Q(2,2) + pi_02 * P(2,1) * Q(1,2) + pi_02 * P(2,2) * Q(2,2)) ;
pi(1,2,3) = (pi_01 * P(1,2) * Q(2,3) + pi_02 * P(2,2) * Q(2,3)) / (pi_01 * P(1,1) * Q(1,3) + pi_01 * P(1,2) * Q(2,3) + pi_02 * P(2,1) * Q(1,3) + pi_02 * P(2,2) * Q(2,3)) ;
pi(2,1,1) = (pi(1,1,1)*P(1,1)*Q(1,1) + pi(1,2,1)*P(2,1)*Q(1,1)) / (pi(1,1,1)*P(1,1)*Q(1,1) + pi(1,1,1)*P(1,2)*Q(2,1) + pi(1,2,1)*P(2,1)*Q(1,1) + pi(1,2,1)*P(2,2)*Q(2,1)) ; % this will be used in the eq(14), eq(15), eq(16), theta1 = theta2 = 1
pi(2,2,1) = (pi(1,1,1)*P(1,2)*Q(2,1) + pi(1,2,1)*P(2,2)*Q(2,1)) / (pi(1,1,1)*P(1,1)*Q(1,1) + pi(1,1,1)*P(1,2)*Q(2,1) + pi(1,2,1)*P(2,1)*Q(1,1) + pi(1,2,1)*P(2,2)*Q(2,1)) ; % same above
pi(2,1,2) = (pi(1,1,1)*P(1,1)*Q(1,2) + pi(1,2,1)*P(2,1)*Q(1,2)) / (pi(1,1,1)*P(1,1)*Q(1,2) + pi(1,1,1)*P(1,2)*Q(2,2) + pi(1,2,1)*P(2,1)*Q(1,2) + pi(1,2,1)*P(2,2)*Q(2,2)) ; % this will be used in eq(18)
pi(2,2,2) = (pi(1,1,1)*P(1,2)*Q(2,2) + pi(1,2,1)*P(2,2)*Q(2,2)) / (pi(1,1,1)*P(1,1)*Q(1,2) + pi(1,1,1)*P(1,2)*Q(2,2) + pi(1,2,1)*P(2,1)*Q(1,2) + pi(1,2,1)*P(2,2)*Q(2,2)) ; % this will be used in eq(18)
pi(3,1,1) = (pi(2,1,2)*P(1,1)*Q(1,1) + pi(2,2,2)*P(2,1)*Q(1,1)) / (pi(2,1,2)*P(1,1)*Q(1,1) + pi(2,1,2)*P(1,2)*Q(2,1) + pi(2,2,2)*P(2,1)*Q(1,1) + pi(2,2,2)*P(2,2)*Q(2,1)) ; % this will be used in eq(18)
pi(3,2,1) = (pi(2,1,2)*P(1,2)*Q(2,1) + pi(2,2,2)*P(2,2)*Q(2,1)) / (pi(2,1,2)*P(1,1)*Q(1,1) + pi(2,1,2)*P(1,2)*Q(2,1) + pi(2,2,2)*P(2,1)*Q(1,1) + pi(2,2,2)*P(2,2)*Q(2,1)) ; % this will be used in eq(18)
pi(3,1,2) = (pi(2,1,2)*P(1,1)*Q(1,2) + pi(2,2,2)*P(2,1)*Q(1,2)) / (pi(2,1,2)*P(1,1)*Q(1,2) + pi(2,1,2)*P(1,2)*Q(2,2) + pi(2,2,2)*P(2,1)*Q(1,2) + pi(2,2,2)*P(2,2)*Q(2,2)) ; % this will be used in eq(19)
pi(3,2,2) = (pi(2,1,2)*P(1,2)*Q(2,2) + pi(2,2,2)*P(2,2)*Q(2,2)) / (pi(2,1,2)*P(1,1)*Q(1,2) + pi(2,1,2)*P(1,2)*Q(2,2) + pi(2,2,2)*P(2,1)*Q(1,2) + pi(2,2,2)*P(2,2)*Q(2,2)) ; % this will be used in eq(19)
pi(3,1,1,1) = (pi(2,1,1)*P(1,1)*Q(1,1) + pi(2,2,1)*P(2,1)*Q(1,1)) / (pi(2,1,1)*P(1,1)*Q(1,1) + pi(2,1,1)*P(1,2)*Q(2,1) + pi(2,2,1)*P(2,1)*Q(1,1) + pi(2,2,1)*P(2,2)*Q(2,1)) ;
pi(3,2,1,1) = (pi(2,1,1)*P(1,2)*Q(2,1) + pi(2,2,1)*P(2,2)*Q(2,1)) / (pi(2,1,1)*P(1,1)*Q(1,1) + pi(2,1,1)*P(1,2)*Q(2,1) + pi(2,2,1)*P(2,1)*Q(1,1) + pi(2,2,1)*P(2,2)*Q(2,1)) ;
pi(4,1,1) = (pi(3,1,1,1)*P(1,1)*Q(1,1) + pi(3,2,1,1)*P(2,1)*Q(1,1)) / (pi(3,1,1,1)*P(1,1)*Q(1,1) + pi(3,1,1,1)*P(1,2)*Q(2,1) + pi(3,2,1,1)*P(2,1)*Q(1,1) + pi(3,2,1,1)*P(2,2)*Q(2,1)) ;
pi(4,2,1) = (pi(3,1,1,1)*P(1,2)*Q(2,1) + pi(3,2,1,1)*P(2,2)*Q(2,1)) / (pi(3,1,1,1)*P(1,1)*Q(1,1) + pi(3,1,1,1)*P(1,2)*Q(2,1) + pi(3,2,1,1)*P(2,1)*Q(1,1) + pi(3,2,1,1)*P(2,2)*Q(2,1)) ;
syms t; % for integral variable
eq(1) = pi_01 * exp(- exp(x(6) * 1) * (Tr(1)/x(5))^x(4)) * x(4)/x(5) * (Tr(1)/x(5))^(x(4)-1) * exp(x(6)*1) + pi_02 * exp(- exp(x(6)*2) * (Tr(1)/x(5))^x(4)) * x(4)/x(5) * (Tr(1)/x(5))^(x(4)-1) * exp(x(6)*2);
eq(2) = pi_01 * exp(- exp(x(6) * 1) * (Tr(2)/x(5))^x(4)) * x(4)/x(5) * (Tr(2)/x(5))^(x(4)-1) * exp(x(6)*1) + pi_02 * exp(- exp(x(6)*2) * (Tr(2)/x(5))^x(4)) * x(4)/x(5) * (Tr(2)/x(5))^(x(4)-1) * exp(x(6)*2);
eq(3) = pi_01 * exp(- exp(x(6) * 1) * (Tr(3)/x(5))^x(4)) * x(4)/x(5) * (Tr(3)/x(5))^(x(4)-1) * exp(x(6)*1) + pi_02 * exp(- exp(x(6)*2) * (Tr(3)/x(5))^x(4)) * x(4)/x(5) * (Tr(3)/x(5))^(x(4)-1) * exp(x(6)*2);
eq(4) = pi_01 * exp(- exp(x(6) * 1) * (Tr(4)/x(5))^x(4)) * x(4)/x(5) * (Tr(4)/x(5))^(x(4)-1) * exp(x(6)*1) + pi_02 * exp(- exp(x(6)*2) * (Tr(4)/x(5))^x(4)) * x(4)/x(5) * (Tr(4)/x(5))^(x(4)-1) * exp(x(6)*2);
eq(5) = pi_01 * exp(- exp(x(6) * 1) * (Tr(5)/x(5))^x(4)) * x(4)/x(5) * (Tr(5)/x(5))^(x(4)-1) * exp(x(6)*1) + pi_02 * exp(- exp(x(6)*2) * (Tr(5)/x(5))^x(4)) * x(4)/x(5) * (Tr(5)/x(5))^(x(4)-1) * exp(x(6)*2);
eq(6) = pi_01 * exp(- exp(x(6) * 1) * (Tr(6)/x(5))^x(4)) * x(4)/x(5) * (Tr(6)/x(5))^(x(4)-1) * exp(x(6)*1) + pi_02 * exp(- exp(x(6)*2) * (Tr(6)/x(5))^x(4)) * x(4)/x(5) * (Tr(6)/x(5))^(x(4)-1) * exp(x(6)*2);
eq(7) = pi_01 * exp(- exp(x(6) * 1) * (Tr(7)/x(5))^x(4)) * x(4)/x(5) * (Tr(7)/x(5))^(x(4)-1) * exp(x(6)*1) + pi_02 * exp(- exp(x(6)*2) * (Tr(7)/x(5))^x(4)) * x(4)/x(5) * (Tr(7)/x(5))^(x(4)-1) * exp(x(6)*2);
eq(8) = pi_01 * exp(- exp(x(6) * 1) * (Tr(8)/x(5))^x(4)) * x(4)/x(5) * (Tr(8)/x(5))^(x(4)-1) * exp(x(6)*1) + pi_02 * exp(- exp(x(6)*2) * (Tr(8)/x(5))^x(4)) * x(4)/x(5) * (Tr(8)/x(5))^(x(4)-1) * exp(x(6)*2); % from equ(1) to equ(8) Tr is below 1
eq(9) = ( pi_01*P(1,1)*Q(1,3) + pi_01*P(1,2)*Q(2,3) + pi_02*P(2,1)*Q(1,3) + pi_02*P(2,2)*Q(2,3) ) * ( pi_01*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,0,1)) + pi_02*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,0,1)) ) * ( pi(1,1,3) * exp(- exp(x(6) * 1) * ( ( (Tr(9)) / x(5))^x(4) - (1/x(5))^x(4))) * x(4)/x(5) * ((Tr(9))/x(5))^(x(4)-1) * exp(x(6)*1) + pi(1,2,3) * exp(- exp(x(6)*2) * (((Tr(9))/x(5))^x(4) - (1/x(5))^x(4))) * x(4)/x(5) * ((Tr(9)-1)/x(5))^(x(4)-1) * exp(x(6)*2) ); % Tr(i), theta in Q(j,thata) and theta in pi(k,i,theta) should be changed
eq(10) = ( pi_01*P(1,1)*Q(1,1) + pi_01*P(1,2)*Q(2,1) + pi_02*P(2,1)*Q(1,1) + pi_02*P(2,2)*Q(2,1) ) * ( pi_01*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,0,1)) + pi_02*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,0,1)) ) * ( pi(1,1,1) * exp(- exp(x(6) * 1) * ( ( (Tr(10)) / x(5))^x(4) - (1/x(5))^x(4))) * x(4)/x(5) * ((Tr(10))/x(5))^(x(4)-1) * exp(x(6)*1) + pi(1,2,1) * exp(- exp(x(6)*2) * (((Tr(10))/x(5))^x(4) - (1/x(5))^x(4))) * x(4)/x(5) * ((Tr(10))/x(5))^(x(4)-1) * exp(x(6)*2) );
eq(11) = ( pi_01*P(1,1)*Q(1,1) + pi_01*P(1,2)*Q(2,1) + pi_02*P(2,1)*Q(1,1) + pi_02*P(2,2)*Q(2,1) ) * ( pi_01*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,0,1)) + pi_02*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,0,1)) ) * ( pi(1,1,1) * exp(- exp(x(6) * 1) * ( ( (Tr(11)) / x(5))^x(4) - (1/x(5))^x(4))) * x(4)/x(5) * ((Tr(11))/x(5))^(x(4)-1) * exp(x(6)*1) + pi(1,2,1) * exp(- exp(x(6)*2) * (((Tr(11))/x(5))^x(4) - (1/x(5))^x(4))) * x(4)/x(5) * ((Tr(11))/x(5))^(x(4)-1) * exp(x(6)*2) );
eq(12) = ( pi_01*P(1,1)*Q(1,1) + pi_01*P(1,2)*Q(2,1) + pi_02*P(2,1)*Q(1,1) + pi_02*P(2,2)*Q(2,1) ) * ( pi_01*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,0,1)) + pi_02*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,0,1)) ) * ( pi(1,1,1) * exp(- exp(x(6) * 1) * ( ( (Tr(12)) / x(5))^x(4) - (1/x(5))^x(4))) * x(4)/x(5) * ((Tr(12))/x(5))^(x(4)-1) * exp(x(6)*1) + pi(1,2,1) * exp(- exp(x(6)*2) * (((Tr(12))/x(5))^x(4) - (1/x(5))^x(4))) * x(4)/x(5) * ((Tr(12))/x(5))^(x(4)-1) * exp(x(6)*2) );
eq(13) = ( pi_01*P(1,1)*Q(1,2) + pi_01*P(1,2)*Q(2,2) + pi_02*P(2,1)*Q(1,2) + pi_02*P(2,2)*Q(2,2) ) * ( pi_01*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,0,1)) + pi_02*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,0,1)) ) * ( pi(1,1,2) * exp(- exp(x(6) * 1) * ( ( (Tr(13)) / x(5))^x(4) - (1/x(5))^x(4))) * x(4)/x(5) * ((Tr(13))/x(5))^(x(4)-1) * exp(x(6)*1) + pi(1,2,2) * exp(- exp(x(6)*2) * (((Tr(13))/x(5))^x(4) - (1/x(5))^x(4))) * x(4)/x(5) * ((Tr(13))/x(5))^(x(4)-1) * exp(x(6)*2) );
eq(14) = ( ( pi_01*P(1,1)*Q(1,1) + pi_01*P(1,2)*Q(2,1) + pi_02*P(2,1)*Q(1,1) + pi_02*P(2,2)*Q(2,1) ) * ( pi(1,1,1)*P(1,1)*Q(1,1) + pi(1,1,1)*P(1,2)*Q(2,1) + pi(1,2,1)*P(2,1)*Q(1,1) + pi(1,2,1)*P(2,2)*Q(2,1)) ) * ( ( pi_01*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,0,1)) + pi_02*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,0,1)) ) * ( pi(1,1,1)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,1,2)) + pi(1,2,1)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,1,2)) ) ) * ( ( pi(2,1,1) * exp(- exp(x(6) * 1) * ( ( (Tr(14)) / x(5))^x(4) - (2/x(5))^x(4))) * x(4)/x(5) * ((Tr(14))/x(5))^(x(4)-1) * exp(x(6)*1) + pi(2,2,1) * exp(- exp(x(6)*2) * (((Tr(14))/x(5))^x(4) - (2/x(5))^x(4))) * x(4)/x(5) * ((Tr(14))/x(5))^(x(4)-1) * exp(x(6)*2) ) );
eq(15) = ( ( pi_01*P(1,1)*Q(1,1) + pi_01*P(1,2)*Q(2,1) + pi_02*P(2,1)*Q(1,1) + pi_02*P(2,2)*Q(2,1) ) * ( pi(1,1,1)*P(1,1)*Q(1,1) + pi(1,1,1)*P(1,2)*Q(2,1) + pi(1,2,1)*P(2,1)*Q(1,1) + pi(1,2,1)*P(2,2)*Q(2,1)) ) * ( ( pi_01*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,0,1)) + pi_02*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,0,1)) ) * ( pi(1,1,1)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,1,2)) + pi(1,2,1)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,1,2)) ) ) * ( ( pi(2,1,1) * exp(- exp(x(6) * 1) * ( ( (Tr(15)) / x(5))^x(4) - (2/x(5))^x(4))) * x(4)/x(5) * ((Tr(15))/x(5))^(x(4)-1) * exp(x(6)*1) + pi(2,2,1) * exp(- exp(x(6)*2) * (((Tr(15))/x(5))^x(4) - (2/x(5))^x(4))) * x(4)/x(5) * ((Tr(15))/x(5))^(x(4)-1) * exp(x(6)*2) ) );
eq(16) = ( ( pi_01*P(1,1)*Q(1,2) + pi_01*P(1,2)*Q(2,2) + pi_02*P(2,1)*Q(1,2) + pi_02*P(2,2)*Q(2,2) ) * ( pi(1,1,2)*P(1,1)*Q(1,2) + pi(1,1,2)*P(1,2)*Q(2,2) + pi(1,2,2)*P(2,1)*Q(1,2) + pi(1,2,2)*P(2,2)*Q(2,2)) ) * ( ( pi_01*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,0,1)) + pi_02*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,0,1)) ) * ( pi(1,1,2)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,1,2)) + pi(1,2,2)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,1,2)) ) ) * ( ( pi(2,1,2) * exp(- exp(x(6) * 1) * ( ( (Tr(16)) / x(5))^x(4) - (2/x(5))^x(4))) * x(4)/x(5) * ((Tr(16))/x(5))^(x(4)-1) * exp(x(6)*1) + pi(2,2,2) * exp(- exp(x(6)*2) * (((Tr(16))/x(5))^x(4) - (2/x(5))^x(4))) * x(4)/x(5) * ((Tr(16))/x(5))^(x(4)-1) * exp(x(6)*2) ) ); % I didn't define the value of pi(2,1,2) and pi(2,2,2)
eq(17) = ( ( pi_01*P(1,1)*Q(1,1) + pi_01*P(1,2)*Q(2,1) + pi_02*P(2,1)*Q(1,1) + pi_02*P(2,2)*Q(2,1) ) * ( pi(1,1,1)*P(1,1)*Q(1,1) + pi(1,1,1)*P(1,2)*Q(2,1) + pi(1,2,1)*P(2,1)*Q(1,1) + pi(1,2,1)*P(2,2)*Q(2,1)) ) * ( ( pi_01*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,0,1)) + pi_02*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,0,1)) ) * ( pi(1,1,1)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,1,2)) + pi(1,2,1)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,1,2)) ) ) * ( ( pi(2,1,1) * exp(- exp(x(6) * 1) * ( ( (Tr(17)) / x(5))^x(4) - (2/x(5))^x(4))) * x(4)/x(5) * ((Tr(17))/x(5))^(x(4)-1) * exp(x(6)*1) + pi(2,2,1) * exp(- exp(x(6)*2) * (((Tr(17))/x(5))^x(4) - (2/x(5))^x(4))) * x(4)/x(5) * ((Tr(17))/x(5))^(x(4)-1) * exp(x(6)*2) ) );
eq(18) = ( ( pi_01*P(1,1)*Q(1,1) + pi_01*P(1,2)*Q(2,1) + pi_02*P(2,1)*Q(1,1) + pi_02*P(2,2)*Q(2,1) ) * ( pi(1,1,1)*P(1,1)*Q(1,2) + pi(1,1,1)*P(1,2)*Q(2,2) + pi(1,2,1)*P(2,1)*Q(1,2) + pi(1,2,1)*P(2,2)*Q(2,2) ) * ( pi(2,1,2)*P(1,1)*Q(1,1) + pi(2,1,2)*P(1,2)*Q(2,1) + pi(2,2,2)*P(2,1)*Q(1,1) + pi(2,2,2)*P(2,2)*Q(2,1)) ) * ( ( pi_01*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,0,1)) + pi_02*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,0,1)) ) * ( pi(1,1,1)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,1,2)) + pi(1,2,1)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,1,2)) ) * ( pi(2,1,2)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,2,3)) + pi(2,2,2)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,2,3)) ) ) * ( pi(3,1,1) * exp(- exp(x(6) * 1) * ( (Tr(18)/x(5))^x(4) - (3/x(5))^x(4))) * x(4)/x(5) * (Tr(18)/x(5))^(x(4)-1) * exp(x(6)*1) + pi(3,2,1) * exp(- exp(x(6) * 2) * ( (Tr(18)/x(5))^x(4) - (3/x(5))^x(4))) * x(4)/x(5) * (Tr(18)/x(5))^(x(4)-1) * exp(x(6)*2) );
eq(19) = ( ( pi_01*P(1,1)*Q(1,1) + pi_01*P(1,2)*Q(2,1) + pi_02*P(2,1)*Q(1,1) + pi_02*P(2,2)*Q(2,1) ) * ( pi(1,1,1)*P(1,1)*Q(1,2) + pi(1,1,1)*P(1,2)*Q(2,2) + pi(1,2,1)*P(2,1)*Q(1,2) + pi(1,2,1)*P(2,2)*Q(2,2) ) * ( pi(2,1,2)*P(1,1)*Q(1,1) + pi(2,1,2)*P(1,2)*Q(2,1) + pi(2,2,2)*P(2,1)*Q(1,1) + pi(2,2,2)*P(2,2)*Q(2,1)) ) * ( ( pi_01*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,0,1)) + pi_02*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,0,1)) ) * ( pi(1,1,1)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,1,2)) + pi(1,2,1)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,1,2)) ) * ( pi(2,1,2)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,2,3)) + pi(2,2,2)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,2,3)) ) ) * ( pi(3,1,2) * exp(- exp(x(6) * 1) * ( (Tr(19)/x(5))^x(4) - (3/x(5))^x(4))) * x(4)/x(5) * (Tr(19)/x(5))^(x(4)-1) * exp(x(6)*1) + pi(3,2,2) * exp(- exp(x(6) * 2) * ( (Tr(19)/x(5))^x(4) - (3/x(5))^x(4))) * x(4)/x(5) * (Tr(19)/x(5))^(x(4)-1) * exp(x(6)*2) );
eq(20) = ( ( pi_01*P(1,1)*Q(1,1) + pi_01*P(1,2)*Q(2,1) + pi_02*P(2,1)*Q(1,1) + pi_02*P(2,2)*Q(2,1) ) * ( pi(1,1,1)*P(1,1)*Q(1,1) + pi(1,1,1)*P(1,2)*Q(2,1) + pi(1,2,1)*P(2,1)*Q(1,1) + pi(1,2,1)*P(2,2)*Q(2,1) ) * ( pi(2,1,1)*P(1,1)*Q(1,1) + pi(2,1,1)*P(1,2)*Q(2,1) + pi(2,2,1)*P(2,1)*Q(1,1) + pi(2,2,1)*P(2,2)*Q(2,1)) * ( pi(3,1,1)*P(1,1)*Q(1,1) + pi(3,1,1)*P(1,2)*Q(2,1) + pi(3,2,1)*P(2,1)*Q(1,1) + pi(3,2,1)*P(2,2)*Q(2,1)) ) * ( ( pi_01*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,0,1)) + pi_02*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,0,1)) ) * ( pi(1,1,1)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,1,2)) + pi(1,2,1)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,1,2)) ) * ( pi(2,1,1)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,2,3)) + pi(2,2,1)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,2,3)) ) * ( pi(3,1,1,1)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(x(6)),t,3,4)) + pi(3,2,1,1)*exp(-int(x(4)/x(5)*(t/x(5))^(x(4)-1)*exp(2*x(6)),t,3,4)) ) ) * ( pi(4,1,1) * exp(- exp(x(6) * 1) * ( (Tr(20)/x(5))^x(4) - (4/x(5))^x(4))) * x(4)/x(5) * (Tr(20)/x(5))^(x(4)-1) * exp(x(6)*1) + pi(4,2,1) * exp(- exp(x(6) * 2) * ( (Tr(20)/x(5))^x(4) - (4/x(5))^x(4))) * x(4)/x(5) * (Tr(20)/x(5))^(x(4)-1) * exp(x(6)*2) );
equation = @(x) (-(log(eq(1)) + log(eq(2)) + log(eq(3)) + log(eq(4)) + log(eq(5)) + log(eq(6)) + log(eq(7)) + log(eq(8)) + log(eq(9)) + log(eq(10)) + log(eq(11)) + log(eq(12)) + log(eq(13)) + log(eq(14)) + log(eq(15)) + log(eq(16)) + log(eq(17)) + log(eq(18)) + log(eq(19)) + log(eq(20))));
x0 = [0;0;0;0;0;0];
[x,fval] = fminsearch(equation, x0)
-------------------------------------------------------------------------------
0 个评论
采纳的回答
Sargondjani
2012-7-3
编辑:Sargondjani
2012-7-3
i dont know what you want this to do: x = sym(zeros(6,1)); for i=1:1:6 x(i) = sym(sprintf('x%d',i)); end
or: syms t
but it looks like it should work if you leave out these parts...
also note that "pi" is reserved for pi, so you should not use that name
更多回答(1 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!