MATLAB: How to use subs to help fmincon in optimizing integral

fminconMATLABsymbolic

Hi,
I am a student now and want to find an optimal solution for my profit function.
I want to use fmincon cause my variable will be more than zero. The problem is fmincon do not accept symbolic so I cannot use it.
My code for my objective function is
function b = three_var(v)
Q= v(1)
q_1=v(2)
q_2=v(3)
p=200;
w_1=100;
w_2=90;
g=40;
v=30;
W_ec1=140;
W_ec2=130;
W_ep1=60;
W_ep2=70
o_1=10;
o_2=11;
k=0.1;
j=0.9;
syms x;
D1 = int((W_ep1*q_1+W_ep2*q_2+p*x+v*(Q-q_1-q_2-x))*(1/300),x,700,Q-q_1-q_2)
D2 = int((W_ep1*k*(Q-x)+W_ep2*(1-k)*(Q-x)+p*x)*(1/300),x,Q-q_1-q_2,Q)
D3 = int((p*x-(W_ec1*k*(x-Q))-(W_ec2*(1-k)*(x-Q)))*(1/300),Q,Q+q_1+q_2)
D4 = int((p*(Q+q_1+q_2)-(W_ec1*q_1+W_ec2*q_2)-g*(x-(Q+q_1+q_2)))*(1/300),x,Q+q_1+q_2,1000)
b = -(w_1*j*Q)-(w_2*(1-j)*Q)-(o_1*q_1)-(o_2*q_2)+D1+D2+D3+D4
The constraint is just Q,q_1,q_2>0
Can you guys help me with this problem?
Is there any example of how to use subs to help in this case?
Thank you very much

Best Answer

Add to the end
b = double(b);