Unable to convert expression into double array
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Matt J
le 28 Jan 2020
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 commentaires
Plus de réponses (1)
Walter Roberson
le 28 Jan 2020
Modifié(e) : Walter Roberson
le 28 Jan 2020
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 commentaires
Voir également
Catégories
En savoir plus sur Assumptions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!