Cropping xyz data in MATLAB

2 visualizzazioni (ultimi 30 giorni)
Charlotte Findlay
Charlotte Findlay il 4 Mag 2018
I am trying to crop an xyz data set (see figure attached) in MATLAB.
The file is too large to convert into a .txt file first and I was wondering if it is possible to do this in MATLAB?
I am looking to retain all xyz data from 55 to 60 degrees latitude (Y) and -4 to -8 degrees longitude (X).
Any help would be much appreciated.

Risposta accettata

Wick
Wick il 4 Mag 2018
You're trying to extract the data from the image file?
imread will work find for this purpose. It will return an mxnx3 variable where each page represents the red, green, and blue values for each pixel respectively.
Or do you already have the data in MATLAB and you only want to take a small chunk of it? In that case, it would help to know the shape of the data. But I'll assume for the moment that you've got two vectors, LAT, and LON that represent the ranges of latitude and longitude and a 2D variable BATH. Let's assume LAT is a column vector, and LON is a row vector. BATH should be [length(LAT) length(LON)] in size.
LAT_index = LAT >= 55 & LAT <= 60;
LON_index = LON >= -8 & LON <= -4;
LAT_subset = LAT(LAT_index);
LON_subset = LON(LON_index);
BATH_subset = BATH(LAT_index,LON_index);

Più risposte (0)

Categorie

Scopri di più su Lighting, Transparency, and Shading in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by