![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1353759/image.png)
How can I use syms like theta_(i-1)?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
서호 이
am 12 Apr. 2023
Kommentiert: 서호 이
am 25 Apr. 2023
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) ...
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 12 Apr. 2023
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1353759/image.png)
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]
3 Kommentare
Walter Roberson
am 14 Apr. 2023
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
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!