Adjust randomly-distributed matrix to a organised matrix
2 views (last 30 days)
Show older comments
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
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')
Answers (0)
See Also
Categories
Find more on Geodesy and Mapping in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!