根据 The loop 的索引命名 veriable

Naming veriable according to The index of The loop

for i=1:1:4 
    T=[(cos(x(i)))^2 (sin(x(i)))^2 2*(cos(x(i)))*(sin(x(i)));(sin(x(i)))^2 (cos(x(i)))^2 -2*(cos(x(i)))*(sin(x(i))) ;-(cos(x(i)))*(sin(x(i))) (cos(x(i)))*(sin(x(i))) (cos(x(i)))^2-(sin(x(i)))^2 ;];
    XXXXX=inv(T)*Qq*R*T*inv(R);
end

我想根据i命名XXXXX;我的意思是当 i=1 是 运行 时,XXXXX 将是可变的 Q1,而 i=2 将是 Q2,等等。

使用变量名Q1 Q2 Q3是possible but not recommended。 link 解释了为什么不推荐它以及如何实现它。

相反,使用 cell array 来存储您的结果:

n=4; % or probably better n=numel(x)
Q=cell(n,1);
for i=1:1:4; 
    T=[(cos(x(i)))^2 (sin(x(i)))^2 2*(cos(x(i)))*(sin(x(i)));(sin(x(i)))^2 (cos(x(i)))^2 -2*(cos(x(i)))*(sin(x(i))) ;-(cos(x(i)))*(sin(x(i))) (cos(x(i)))*(sin(x(i))) (cos(x(i)))^2-(sin(x(i)))^2 ;];
    Q{i}=inv(T)*Qq*R*T*inv(R);
end