Issue converting symbolic function to double array
Afficher commentaires plus anciens
I am trying to define a set of symbolic functions (whose values rely on one another, changing as time goes on) such that I can solve for the numeric value of a final symbolic function. However, I keep getting an error when I try to get a double array from the final symbolic function. Here is my code:
Definition of Key Vars %%%
t = 1:1:100
m = 1.0
n = 2
g = 1
Equations %%%
syms q(t) p(t) r(t) v(t) H(t)
q(t) = log(cosh(t))
p(t) = exp(-1 * (q(t) - q(t - 1))) - exp(-1 * (q(t + 1) - q(t)))
H(t) = .5 * p(t)^2 + g * exp(2*(q(t)-q(t+1)))
disp(double(H))
I have also tried using vpa then using double, but the same error persists-
Error using symengine
Unable to convert expression into double array.
Error in sym/double (line 661)
Xstr = mupadmex('symobj::double', S.s, 0);
Error in toda_model (line 31)
disp(double(H))
Réponses (1)
madhan ravi
le 2 Nov 2018
Definition of Key Vars %%%
t = 1:1:100
m = 1.0
n = 2
g = 1
Equations %%%
q = @(t)log(cosh(t))
q(t)
p= @(t)exp(-1 .* (q(t) - q(t - 1))) - exp(-1 * (q(t + 1) - q(t)))
p(t)
H= @(t).5.* p(t).^2 + g .* exp(2.*(q(t)-q(t+1)))
disp((H(t)))
Catégories
En savoir plus sur Conversion dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!