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

1 次查看(过去 30 天)
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

采纳的回答

Jan
Jan 2022-7-5
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);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 3-D Scene Control 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by