Create matrix with elements representing distance from centre of matrix
Mostra commenti meno recenti
Hello. If i have a 3x3, 5x5 or 7x7 matrix or generally a nxn matrix where n is odd, i want each element to represent the distance from the centre of the matrix. I.e the top left element in a 3x3 matrix to represent up one row and left 1 column. I.e (1,-1).
I then want to unravel this matrix into a 1D vector but in a serpentine fashion rather than raster scan
Risposta accettata
Più risposte (2)
darova
il 31 Gen 2021
What about this?
m = 5;
n = (m-1)/2;
[X,Y] = meshgrid(-n:n);
A = sqrt(X.^2+Y.^2)
surf(A)

Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!