Evaluate a vectorial symbolic matlab function through Matrices and vectors directly
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello everyone,
I'm actually working with the symbolic toolbox, and I want to evaluate a matlab symbolic function that depends on a matrix and a vector which the dimension changes in the general application.
However, when I want to evaluate the final result, the error message tells me that I have to pass on the members of the matrix and the vector, and it is exactly the thing that I want to avoid.
clear;close;clc;
Msym = sym('M', [8, 2], 'real');
vsym = sym('v', [2, 1], 'real');
q0sym = sym('q0', [8, 1], 'real');
qsym = Msym * vsym + q0sym;
q0 = [0; 0; 0; 1; 0; 0; 0; 1];
M = [0, 0; 0.0164, 0.0109; 0, 0; -0.0005, -0.0005; 0, 0; 0, 0.0553; 0, 0; 0, -0.0011];
v = [0; 0];
q = matlabFunction(qsym)
q_eval = double(q(q0, M, v))
Can anyone help me please to solve this probem ?
P.S: I have already succeeded to solve this problem using "subs", but it is taking long time when the size of Msym and vsym are great.
Thanks in advance.
0 commentaires
Réponse acceptée
Ameer Hamza
le 4 Déc 2020
The function handle is not being created in the way you want. Change the matlabFunction line to
q = matlabFunction(qsym, 'Vars', {q0sym, Msym, vsym})
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox 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!