Cropping xyz data in MATLAB

조회 수: 4 (최근 30일)
Charlotte Findlay
Charlotte Findlay 2018년 5월 4일
댓글: Charlotte Findlay 2018년 5월 9일
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.

채택된 답변

Wick
Wick 2018년 5월 4일
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
Charlotte Findlay
Charlotte Findlay 2018년 5월 9일
Thanks Chad the code you supplied worked!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by