Circular Indexing of Array

I have a question that has been addressed in some capacity here: https://www.mathworks.com/matlabcentral/answers/44993-circular-indexing-of-an-array. However I am not sure how to use this approach for my array. I am clustering data in a 73 x 144 array with bwlabel. However, the data should be treated as circular (rather spherical) as it is Earth Surface data. So I want to be able to apply bwlabel such that the right side of the array is technically continued into the left side of the array. I have tried appending the array such that I tack on 10 or 15 columns on both the left and right side of the array, but that generates false clusters. I have attached an image of my problem. The top center of the image (at North Pole) the pink and light blue clusters should be the same, but are separated by bwlabel since the array begins at 0 degrees longitude and ends at 360 degrees longitude. Any suggestions would be great!

Respuestas (1)

Chad Greene
Chad Greene el 16 de Ag. de 2018

0 votos

If you have lat,lon grids corresponding to your matrix Z, try using the attached function to recenter like this:
[lat,lon,Z] = recenter(lat,lon,Z);
If your lat and lons are 1D arrays, you might need to grid them with meshgrid first by either
[lon,lat] = meshgrid(lon,lat);
or
[lat,lon] = meshgrid(lat,lon);

3 comentarios

Tyler Smith
Tyler Smith el 16 de Ag. de 2018
Thanks for the response Chad. My data does span 0 to 360 longitude, however, if I was to convert the grid to span -180 to 180, wouldn't I still have the same problem as above, where the array is discontinuous on the edge (at 180 degrees) rather than at 0 degrees? Perhaps a better way of framing my issue is I want to be able to manipulate/index the array as not having a longitudinal boundary, rather the reference to the lat long grid should essentially be circular/spherical, where the left and right edges of the 73 x 144 lat lon grid essentially are a continuation of the other side of the array.
Chad Greene
Chad Greene el 16 de Ag. de 2018
Is it prohibitive to triple the size of your dataset, like if
Z = peaks;
then tripling it would look like
Z3 = [Z Z Z];
After doing your analysis, you could get the middle section back, like
Z_analyzed = Z3(:,size(Z,1)+1:2*size(Z,1));
Tyler Smith
Tyler Smith el 17 de Ag. de 2018
The problem that creates is 'bwlabel' or 'labelmatrix' would then generate 3 times the number of clusters since it clusters adjacent cells. There would still be a discontinuous / improper clustering on the edge of the array after extracting the middle section.

Iniciar sesión para comentar.

Categorías

Más información sobre Sparse Matrices en Centro de ayuda y File Exchange.

Preguntada:

el 16 de Ag. de 2018

Comentada:

el 17 de Ag. de 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by