0
我有一個使用四個索引i,j,k和l創建的矩陣。我用下面的方案來創建矩陣,索引矩陣
for i = 1:N
for j = 1:2
for k = 1:2
for l = 1:N
Matrix(l,2(j+2*i-3)+k) = Value
end
end
end
end
當我做到這一點產生變化如下矩陣:
Columns
i = 1 i = 1 i = 1 i = 1 i = 2 i = 2 i = 2 i = 2 ...
j = 1 j = 1 j = 2 j = 2 j = 1 j = 1 j = 2 j = 2 ...
k = 1 k = 2 k = 1 k = 2 k = 1 k = 2 k = 1 k = 2 ...
l = 1
l = 2
.
.
.
不幸的是我索引是錯誤的,需要去改變它。我不想改變任何計算。我需要將上述矩陣變成一個代碼如下:
Columns
l = 1 l = 1 l = 2 l = 2 l = 1 l = 1 l = 2 l = 2 ...
k = 1 k = 2 k = 1 k = 2 k = 1 k = 2 k = 1 k = 2 ...
i = 1 j = 1
i = 1 j = 2
i = 2 j = 1
i = 2 j = 2
.
.
.
換句話說一個代碼,看起來像,
for i = 1:N
for j = 1:2
for k = 1:2
for l = 1:N
Matrix(New Index) = Matrix(Old Index)
end
end
end
end
我該怎麼辦呢?謝謝。
我想有一個很好的理由,爲什麼你不希望只是再次但正確的指數運行的代碼? –
是的,他們是。計算複雜,涉及疊加,多座標變換和2種高斯積分。 –
我認爲,你已經知道正確的指數?換句話說,你知道新指數與舊指數的關係嗎? –