Filter löschen
Filter löschen

Cropping xyz data in MATLAB

3 Ansichten (letzte 30 Tage)
Charlotte Findlay
Charlotte Findlay am 4 Mai 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.

Akzeptierte Antwort

Wick
Wick am 4 Mai 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);
  1 Kommentar
Charlotte Findlay
Charlotte Findlay am 9 Mai 2018
Thanks Chad the code you supplied worked!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by