How to sub sym to a number in a matrix

3 ビュー (過去 30 日間)
Barak Bar-on
Barak Bar-on 2022 年 6 月 26 日
コメント済み: Barak Bar-on 2022 年 6 月 26 日
Hi all,
I have a code calculate the motion equation of 3DOF robotic arm.
In the code I use symbols such as
q = sym('q', [n 1], 'real');
Eventualy I have a 3x1 vector of the motion using alot of symbols on the way
for example, the output for row 1
val =
qdd2*(Izy2*cos(q1) + Izy3*cos(q1) - Izx2*sin(q1) - Izx3*sin(q1) + m3*(4*cos(q1)*sin(q2) +....
How can I subsitute those symbols, q1,q2,Izy,qdd2 and etc to a number?
I use diff() on the way to do diveration from the symbols (q1,q2,q3).,
so Im looking for a way to put the valuses of the symbols at the end, after calculating the motion equations.
I used sub(), didnt work..
thanks in advance.

採用された回答

Walter Roberson
Walter Roberson 2022 年 6 月 26 日
subs(val, q(1:2), [VALUE1; VALUE2])
  3 件のコメント
Walter Roberson
Walter Roberson 2022 年 6 月 26 日
yes
Barak Bar-on
Barak Bar-on 2022 年 6 月 26 日
thank, I had a problem with definde the sym on the vector.
thank you!

サインインしてコメントする。

その他の回答 (1 件)

John D'Errico
John D'Errico 2022 年 6 月 26 日
syms x y z
M = [x-2,x+y,z^2]
M = 
subs(M,[x,z],[1 3])
ans = 
  1 件のコメント
Barak Bar-on
Barak Bar-on 2022 年 6 月 26 日
thanks for the help!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFormula Manipulation and Simplification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by