Borrar filtros
Borrar filtros

Replace x with x(t) in a symbolic matrix

3 visualizaciones (últimos 30 días)
Venkatesh Sripada
Venkatesh Sripada el 12 de Ag. de 2019
Comentada: Venkatesh Sripada el 12 de Ag. de 2019
Hello,
I have a 3x3 symbolic matrix T1. I want to replace theta1 with theta1(t), theta2 with theta2(t) in my matrix. I tried using the subs function like so
syms theta1 theta2 theta3
AT1 = subs(T1, {theta1, theta2, theta3},...
{theta1(t), theta2(t), theta3(t)})
%--------------- My T1 is-----------
[ cos(theta1 + theta2 + theta3), sin(theta1 + theta2 + theta3), 0, 8*cos(theta1 + theta2 + theta3) + 5*cos(theta1 + theta2) + 10*cos(theta1)]
[ -sin(theta1 + theta2 + theta3), cos(theta1 + theta2 + theta3), 0, - 8*sin(theta1 + theta2 + theta3) - 5*sin(theta1 + theta2) - 10*sin(theta1)]
[ 0, 0, 1, 0]
[ 0, 0, 0, 1]
but matlab expects an arithmetic expression as the input function in "subs", hence throws an error.
A workaround I thought of, was calling elements individually and converting them, but however I try an error shows up when I use brackets. By which I mean 'theta1' can be replaced by 'theta4' but not 'theta4(t)'.
In the end I need to differentiate T1, so theta has to be theta(t) for "diff" function to work properly
Please let me know how I can solve this issue.
PS: It is also fine if there is some way I can call elements of the matrix below, but I don't think it is possible
>> T10
T10(t) =
[ cos(theta1(t)), sin(theta1(t)), 0, 10*cos(theta1(t))]
[ -sin(theta1(t)), cos(theta1(t)), 0, -10*sin(theta1(t))]
[ 0, 0, 1, 0]
[ 0, 0, 0, 1]
Thanks,
Venkatesh.

Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Ag. de 2019
syms theta1 theta2 theta3
T = [ cos(theta1 + theta2 + theta3), sin(theta1 + theta2 + theta3), 0, 8*cos(theta1 + theta2 + theta3) + 5*cos(theta1 + theta2) + 10*cos(theta1)
-sin(theta1 + theta2 + theta3), cos(theta1 + theta2 + theta3), 0, - 8*sin(theta1 + theta2 + theta3) - 5*sin(theta1 + theta2) - 10*sin(theta1)
0, 0, 1, 0
0, 0, 0, 1];
syms theta4(t) theta5(t) theta6(t)
temp = subs(T, {theta1, theta2, theta3}, {theta4, theta5, theta6});
syms theta1(t) theta2(t) theta3(t)
AT1 = subs(temp, {theta4, theta5, theta6}, {theta1, theta2, theta3});
"It is also fine if there is some way I can call elements of the matrix below,"
T10(t) =
[ cos(theta1(t)), sin(theta1(t)), 0, 10*cos(theta1(t))]
That is not a matrix: it is a symbolic function that returns a matrix. You cannot access individual elements of the function through normal indexing. You can, however, use formula(T10) which will return an array result that is not a function, and then you can index the array result.
  3 comentarios
Walter Roberson
Walter Roberson el 12 de Ag. de 2019
If you are looking at seperating out those things, then I recommend that you have a look at odeFunction() and the workflow shown in the first example, including odeToVectorField
Venkatesh Sripada
Venkatesh Sripada el 12 de Ag. de 2019
Will look into. Thank you very much

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by