Circular indexing of a 2D array
Ältere Kommentare anzeigen
My Tp matrix is as follows,
1 2 3 7
Tp= 4 5 6 5
7 8 9 8
The code is,
for i=1:3
for j=1:4
if i==1 && j==1
T(i,j)=Tp(i,j-1)
end
if i==2 && j==4
T(i,j)=Tp(i,j+1)
end
end
end
I want the answer of the first IF condition to be T(i,j)=7, which is the element on the other side of the Tp matrix.
Second IF condition answer to be T(i,j)=4, which is the element on the other side of the Tp matrix.
How will I be able to do this?
Thanks in advance.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!