How to output a new matrix that swaps the position of the beginning and end of a separate matrix
2 views (last 30 days)
The project I'm currently working on involves the use of global data with latitudes and longitudes.
I'm extracting data for an area between 13degree W and 30degree E for the longitudinal values. However the data outputed has a linear matrix so 13degree W is actually stored as 347E
My current code is below which outputs the correct data between 347 - 360 followed by zeros for 0-30degrees since the matrix doesn't return to the beginning point.
My question is whether I can simply have matrix return to column 1 when the end of the matrix is met or whether I will need to output a new matrix that swaps their position first.
Thanks for any help you can provide!
Jan on 5 Jul 2022
latitude = zeros(1,18);
longitude = zeros(1,43);
latitude(i) = 48+(i-1)*1;
longitude(j) = mod(347+(j-1)*1, 360);
% Or without loops:
latitude = 48 + ((1:18) - 1)*1;
longitude = mod(347+((1:43) - 1)*1, 360);