Cropping xyz data in MATLAB
4 views (last 30 days)
Show older comments
Charlotte Findlay
on 4 May 2018
Commented: Charlotte Findlay
on 9 May 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.
0 Comments
Accepted Answer
Wick
on 4 May 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);
More Answers (0)
See Also
Categories
Find more on Resizing and Reshaping Matrices 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!