How to output a new matrix that swaps the position of the beginning and end of a separate matrix

1 Ansicht (letzte 30 Tage)
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!
latitude=zeros(1,18);
longitude=zeros(1,43);
for i=1:18
latitude(i)=48+(i-1)*1;
end
for j=1:43
longitude(j)=347+(j-1)*1;
end

Akzeptierte Antwort

Jan
Jan am 5 Jul. 2022
latitude = zeros(1,18);
longitude = zeros(1,43);
for i=1:18
latitude(i) = 48+(i-1)*1;
end
for j=1:43
longitude(j) = mod(347+(j-1)*1, 360);
end
% Or without loops:
latitude = 48 + ((1:18) - 1)*1;
longitude = mod(347+((1:43) - 1)*1, 360);

Weitere Antworten (0)

Kategorien

Mehr zu 3-D Scene Control finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by