필터 지우기
필터 지우기

Adjust randomly-distributed matrix to a organised matrix

조회 수: 1 (최근 30일)
Maurício Andrade
Maurício Andrade 2022년 10월 11일
댓글: Mathieu NOE 2022년 10월 12일
Hello everyone,
I have an adjustment of matrix to handle and I would like to check for help here.
I have a matrix of temperature (T) along a LAT-LON grid, being T(57, 675780) and LAT-LON (675780, 1). I removed duplicates of LAT and LON, but I would like to generate a matrix of T 2D (I mean, considering T(1,:) as the surface layer of the ocean) adjusted to a new LAT (674, 1) and LONG (1440, 1) to plot sea surface temperature. The file is not allowed to upload here since it exceeds 5MB. :(
So, does anyone have a tip to try to solve this? Thank you very much :D
  댓글 수: 3
Maurício Andrade
Maurício Andrade 2022년 10월 11일
I tried to get a piece of the data. So, I added it here as an example. Lat, Lon and temp as (675780, 1). I used these steps on LAT and LON to remove duplicates and create a grid:
[lat, idx] = sort(lat);
lon = lon(idx);
temp = temp(idx);
[lat,ia,ib] = unique(lat); % lat --> (674, 1)
[lon, ja, jb] = unique(lon); %lon --> (1440, 1)
The step I would like to learn is to create a matrix for temp (2D) to be adjusted to the adjusted lat and lon.
Mathieu NOE
Mathieu NOE 2022년 10월 12일
hello
I am not sure about what you are trying to achieve.
your code will remove 99.8 % of the available data and you get almost nothing left from your map
below I tried to show some alternative if the goal is to "downsample" your map
there is no need to create a 2D temp array as scatter works with vectors .
clc
clearvars
load('test.mat')
% this is not needed as lat is monotonically increasing
% [lat, idx] = sort(lat);
% long = long(idx);
% temp = temp(idx);
% let's plot the data as they come
figure(1);
pix = 3; % area of each marker (in points^2).
scatter(long,lat,pix,temp,'filled')
% "decimated" display (any use ?)
decim = 10; % decimation factor
nn = numel(long);
new_ind = 1:decim:nn;
new_lat = lat(new_ind);
new_long = long(new_ind);
new_temp = temp(new_ind);
figure(2);
scatter(new_long,new_lat,pix*decim,new_temp,'filled')
% % your code
% [lat,ia,ib] = unique(lat); % lat --> (674, 1)
% long = long(ia); % lon --> (674, 1)
% temp = temp(ia);
% your code / alternative
[long,ia,ib] = unique(long); % long --> (1440, 1)
lat = lat(ia); % lat --> (1440, 1)
temp = temp(ia);
figure(3);
scatter(long,lat,5,temp,'filled')

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Geodesy and Mapping에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by