Unable to convert expression into double array
8 次查看(过去 30 天)
显示 更早的评论
Dear all,
In the code I would like to use sym function to calculate the first-order derivative of functions F1- F4 and calculate the values of the derivative in special points. But I keep getting this error:
"Error using symengine Unable to convert expression into double array.
Error in sym/double (line 692)
Xstr = mupadmex('symobj::double', S.s, 0);
t = 1.1;
phi = 1.2;
eta_S = 2;
eta_N = eta_S*phi;
sigma = 3;
L_S = 1000;
H_S = 500;
L_N = 800;
H_N = 1600;
z_N_up = 0.99;
z_S_up = 0.98;
syms z_S z_N p_S p_N w_S_H w_N_L w_N_H
F1 = z_N*log(w_S_H*w_N_L/w_N_H) - [log(w_N_L)-log(t)-sigma*(sigma-1)^(-1)*log(phi)];
F2 = z_S*log(w_S_H*w_N_L/w_N_H) - [log(w_N_L)-log(t)-sigma*(sigma-1)^(-1)*log(phi)];
F3 = p_N^(1-sigma) - eta_S^(sigma)*t^(1-sigma)*[(1-sigma)*log(w_S_H)]^(-1)*[w_S_H^(z_N*(1-sigma))-1] - eta_N^(sigma)*w_N_L^(1-sigma)*[(1-sigma)*log(w_N_H/w_N_L)]^(-1)*[(w_N_H/w_N_L)^(1-sigma)-(w_N_H/w_N_L)^(z_N*(1-sigma))];
F4 = p_S^(1-sigma) - eta_S^(sigma)*[(1-sigma)*log(w_S_H)]^(-1)*[w_S_H^(z_S*(1-sigma))-1] - eta_N^(sigma)*t^(1-sigma)*w_N_L^(1-sigma)*[(1-sigma)*log(w_N_H/w_N_L)]^(-1)*[(w_N_H/w_N_L)^(1-sigma)-(w_N_H/w_N_L)^(z_S*(1-sigma))];
F11 = diff(F1,z_S);
F21 = diff(F2,z_S);
F31 = diff(F3,z_S);
F41 = diff(F4,z_S);
double(F11)
double(F21)
double(F31)
double(F41)
How can I obtain the numerical values of F11, F21,F31 and F41 given special values of z_S z_N p_S p_N w_S_H w_N_L w_N_H?
0 个评论
采纳的回答
Matt J
2020-1-28
One way is to convert the symbolic expression to a function with matlabFunction. Then you can pass values to it as for any function.
2 个评论
更多回答(1 个)
Walter Roberson
2020-1-28
编辑:Walter Roberson
2020-1-28
Your F21 and F41 involve several variables including w_N_H. You do not assign values to those variables, so you cannot convert the expression to numeric values.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!