필터 지우기
필터 지우기

How can I use syms like theta_(i-1)?

조회 수: 7 (최근 30일)
서호 이
서호 이 2023년 4월 12일
댓글: 서호 이 2023년 4월 25일
I like to express theta_(i-1) in matlab like theta_i, how can I solve this?
If i use 'theta_i_minus_1' results theta_(i,1) ...

채택된 답변

Walter Roberson
Walter Roberson 2023년 4월 12일
Unfortunately, the current notation does not support subscripts that are general expressions. The current notion supports only (groups of) A to Z and a to z and 0 to 9 as subscripts (does not support underscore in a subscript), with multiple subscripts automatically being spliced together with commas.
I was going to say that "You can have multiple annotations on the main variable but you cannot have annotations on the subscripts. You cannot, for example, construct (theta x double dot)" but that turns out to be at least partly wrong
syms theta_ddot_x theta_x_ddot theta__ddot_x theta_ddot__x theta__ddot__x theta_x_ddot theta_x__ddot theta__x_ddot theta__x__ddot
[theta_ddot_x theta_x_ddot theta__ddot_x theta_ddot__x theta__ddot__x theta_x_ddot theta_x__ddot theta__x_ddot theta__x__ddot]
ans = 
  댓글 수: 3
Walter Roberson
Walter Roberson 2023년 4월 14일
parts = ["theta", "x", "ddot"];
j = ["_", "__"];
orders = [1 2 3; 1 3 2; 2 1 3; 2 3 1; 3 1 2; 3 2 1];
for oidx = 1 : size(orders,1)
tp = parts(orders(oidx,:));
s = [tp(1) + j(1) + tp(2) + j(1) + tp(3), ...
tp(1) + j(1) + tp(2) + j(2) + tp(3), ...
tp(1) + j(2) + tp(2) + j(1) + tp(3), ...
tp(1) + j(2) + tp(2) + j(2) + tp(3)];
disp(s); disp(sym(s));
end
"theta_x_ddot" "theta_x__ddot" "theta__x_ddot" "theta__x__ddot"
"theta_ddot_x" "theta_ddot__x" "theta__ddot_x" "theta__ddot__x"
"x_theta_ddot" "x_theta__ddot" "x__theta_ddot" "x__theta__ddot"
"x_ddot_theta" "x_ddot__theta" "x__ddot_theta" "x__ddot__theta"
"ddot_theta_x" "ddot_theta__x" "ddot__theta_x" "ddot__theta__x"
"ddot_x_theta" "ddot_x__theta" "ddot__x_theta" "ddot__x__theta"
서호 이
서호 이 2023년 4월 25일
Thank you for your effort! I learned more about this :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by