我用这段代码创建了符号矩阵“T”:
for row = 1:n
for col = 1:m
T(row, col) = sym(sprintf('T_%d_%d', row, col));
end
end
对于n = 4,m = 4,结果为:
[ T_1_1, T_1_2, T_1_3, T_1_4]
[ T_2_1, T_2_2, T_2_3, T_2_4]
[ T_3_1, T_3_2, T_3_3, T_3_4]
[ T_4_1, T_4_2, T_4_3, T_4_4]
对于n = 12,m = 12,结果为:
[ T_1_1, T_1_2, T_1_3, T_1_4, T_1_5, T_1_6, T_1_7, T_1_8, T_1_9, T_1_10, T_1_11, T_1_12]
[ T_2_1, T_2_2, T_2_3, T_2_4, T_2_5, T_2_6, T_2_7, T_2_8, T_2_9, T_2_10, T_2_11, T_2_12]
[ T_3_1, T_3_2, T_3_3, T_3_4, T_3_5, T_3_6, T_3_7, T_3_8, T_3_9, T_3_10, T_3_11, T_3_12]
[ T_4_1, T_4_2, T_4_3, T_4_4, T_4_5, T_4_6, T_4_7, T_4_8, T_4_9, T_4_10, T_4_11, T_4_12]
[ T_5_1, T_5_2, T_5_3, T_5_4, T_5_5, T_5_6, T_5_7, T_5_8, T_5_9, T_5_10, T_5_11, T_5_12]
[ T_6_1, T_6_2, T_6_3, T_6_4, T_6_5, T_6_6, T_6_7, T_6_8, T_6_9, T_6_10, T_6_11, T_6_12]
[ T_7_1, T_7_2, T_7_3, T_7_4, T_7_5, T_7_6, T_7_7, T_7_8, T_7_9, T_7_10, T_7_11, T_7_12]
[ T_8_1, T_8_2, T_8_3, T_8_4, T_8_5, T_8_6, T_8_7, T_8_8, T_8_9, T_8_10, T_8_11, T_8_12]
[ T_9_1, T_9_2, T_9_3, T_9_4, T_9_5, T_9_6, T_9_7, T_9_8, T_9_9, T_9_10, T_9_11, T_9_12]
[ T_10_1, T_10_2, T_10_3, T_10_4, T_10_5, T_10_6, T_10_7, T_10_8, T_10_9, T_10_10, T_10_11, T_10_12]
[ T_11_1, T_11_2, T_11_3, T_11_4, T_11_5, T_11_6, T_11_7, T_11_8, T_11_9, T_11_10, T_11_11, T_11_12]
[ T_12_1, T_12_2, T_12_3, T_12_4, T_12_5, T_12_6, T_12_7, T_12_8, T_12_9, T_12_10, T_12_11, T_12_12]
创建T矩阵后,我需要根据T求解m * n线性方程,它们的符号变量为T_i_j。
通过使用求解函数,T_i_j的结果按字母顺序排序如下:
for 4 * 4 :(没问题)
T_1_1: [1x1 sym]
T_1_2: [1x1 sym]
T_1_3: [1x1 sym]
T_1_4: [1x1 sym]
T_2_1: [1x1 sym]
T_2_2: [1x1 sym]
T_2_3: [1x1 sym]
T_2_4: [1x1 sym]
T_3_1: [1x1 sym]
T_3_2: [1x1 sym]
T_3_3: [1x1 sym]
T_3_4: [1x1 sym]
T_4_1: [1x1 sym]
T_4_2: [1x1 sym]
T_4_3: [1x1 sym]
T_4_4: [1x1 sym]
但是对于12 * 12或更高的结果是:
T_1_1: [1x1 sym]
T_1_2: [1x1 sym]
T_1_3: [1x1 sym]
T_1_4: [1x1 sym]
T_1_5: [1x1 sym]
T_1_6: [1x1 sym]
T_1_7: [1x1 sym]
T_1_8: [1x1 sym]
T_1_9: [1x1 sym]
T_10_1: [1x1 sym]
T_1_10: [1x1 sym]
T_10_2: [1x1 sym]
T_11_1: [1x1 sym]
T_1_11: [1x1 sym]
T_10_3: [1x1 sym]
T_11_2: [1x1 sym]
T_12_1: [1x1 sym]
T_1_12: [1x1 sym]
T_10_4: [1x1 sym]
T_11_3: [1x1 sym]
T_12_2: [1x1 sym]
T_10_5: [1x1 sym]
T_11_4: [1x1 sym]
T_12_3: [1x1 sym]
T_10_6: [1x1 sym]
T_11_5: [1x1 sym]
T_12_4: [1x1 sym]
T_10_7: [1x1 sym]
T_11_6: [1x1 sym]
T_12_5: [1x1 sym]
T_10_8: [1x1 sym]
T_11_7: [1x1 sym]
T_12_6: [1x1 sym]
T_10_9: [1x1 sym]
T_11_8: [1x1 sym]
T_12_7: [1x1 sym]
T_11_9: [1x1 sym]
T_12_8: [1x1 sym]
T_12_9: [1x1 sym]
T_10_10: [1x1 sym]
T_10_11: [1x1 sym]
T_11_10: [1x1 sym]
T_10_12: [1x1 sym]
T_11_11: [1x1 sym]
T_12_10: [1x1 sym]
T_11_12: [1x1 sym]
T_12_11: [1x1 sym]
T_12_12: [1x1 sym]
T_2_1: [1x1 sym]
T_2_2: [1x1 sym]
T_2_3: [1x1 sym]
T_2_4: [1x1 sym]
T_2_5: [1x1 sym]
T_2_6: [1x1 sym]
T_2_7: [1x1 sym]
T_2_8: [1x1 sym]
T_2_9: [1x1 sym]
T_2_10: [1x1 sym]
T_2_11: [1x1 sym]
T_2_12: [1x1 sym]
T_3_1: [1x1 sym]
T_3_2: [1x1 sym]
T_3_3: [1x1 sym]
T_3_4: [1x1 sym]
T_3_5: [1x1 sym]
T_3_6: [1x1 sym]
T_3_7: [1x1 sym]
T_3_8: [1x1 sym]
T_3_9: [1x1 sym]
T_3_10: [1x1 sym]
T_3_11: [1x1 sym]
T_3_12: [1x1 sym]
T_4_1: [1x1 sym]
T_4_2: [1x1 sym]
T_4_3: [1x1 sym]
T_4_4: [1x1 sym]
T_4_5: [1x1 sym]
T_4_6: [1x1 sym]
T_4_7: [1x1 sym]
T_4_8: [1x1 sym]
T_4_9: [1x1 sym]
T_4_10: [1x1 sym]
T_4_11: [1x1 sym]
T_4_12: [1x1 sym]
T_5_1: [1x1 sym]
T_5_2: [1x1 sym]
T_5_3: [1x1 sym]
T_5_4: [1x1 sym]
T_5_5: [1x1 sym]
T_5_6: [1x1 sym]
T_5_7: [1x1 sym]
T_5_8: [1x1 sym]
T_5_9: [1x1 sym]
T_5_10: [1x1 sym]
T_5_11: [1x1 sym]
T_5_12: [1x1 sym]
T_6_1: [1x1 sym]
T_6_2: [1x1 sym]
T_6_3: [1x1 sym]
T_6_4: [1x1 sym]
T_6_5: [1x1 sym]
T_6_6: [1x1 sym]
T_6_7: [1x1 sym]
T_6_8: [1x1 sym]
T_6_9: [1x1 sym]
T_6_10: [1x1 sym]
T_6_11: [1x1 sym]
T_6_12: [1x1 sym]
T_7_1: [1x1 sym]
T_7_2: [1x1 sym]
T_7_3: [1x1 sym]
T_7_4: [1x1 sym]
T_7_5: [1x1 sym]
T_7_6: [1x1 sym]
T_7_7: [1x1 sym]
T_7_8: [1x1 sym]
T_7_9: [1x1 sym]
T_7_10: [1x1 sym]
T_7_11: [1x1 sym]
T_7_12: [1x1 sym]
T_8_1: [1x1 sym]
T_8_2: [1x1 sym]
T_8_3: [1x1 sym]
T_8_4: [1x1 sym]
T_8_5: [1x1 sym]
T_8_6: [1x1 sym]
T_8_7: [1x1 sym]
T_8_8: [1x1 sym]
T_8_9: [1x1 sym]
T_8_10: [1x1 sym]
T_8_11: [1x1 sym]
T_8_12: [1x1 sym]
T_9_1: [1x1 sym]
T_9_2: [1x1 sym]
T_9_3: [1x1 sym]
T_9_4: [1x1 sym]
T_9_5: [1x1 sym]
T_9_6: [1x1 sym]
T_9_7: [1x1 sym]
T_9_8: [1x1 sym]
T_9_9: [1x1 sym]
T_9_10: [1x1 sym]
T_9_11: [1x1 sym]
T_9_12: [1x1 sym]
**我如何对12 * 12的结果进行排序如下??? (通过for循环等) (根据T矩阵的行类似排序4 * 4
T_1_1,
T_1_2,
T_1_3,
T_1_4,
T_1_5,
T_1_6,
T_1_7,
T_1_8,
T_1_9,
T_1_10,
T_1_11,
T_1_12,
T_2_1,
T_2_2
T_2_3
.
.
.
T_3_1
T_3_2
.
.
.
这对我来说非常必要。 任何想法请。 最良好的问候! 艾哈迈德
答案 0 :(得分:4)
使用此:
T(row, col) = sym(sprintf('T_%03d_%03d', row, col));
它会将您的数字填充到三位数,因此排序将再次执行正确的操作。