Adjust randomly-distributed matrix to a organised matrix

3 views (last 30 days)
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 Comments
Maurício Andrade
Maurício Andrade on 11 Oct 2022
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 on 12 Oct 2022
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')

Sign in to comment.

Answers (0)

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!