Evaluate a vectorial symbolic matlab function through Matrices and vectors directly
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Ameer Hamza
2020-12-4
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!