Questions about using the find command/function

조회 수: 1 (최근 30일)
Thaís Fernandes
Thaís Fernandes 2018년 7월 30일
댓글: Thaís Fernandes 2018년 7월 30일
I have two arrays of temperatures: sst_a(1800x400) and sst_b(1800x401x366). I also have two latitude matrices and two matrices of longitude: lon_a(400x1), lat_a(1800x1), lon_b(401x1) and lat_b(1800x1). I'd like to map this, excluding temperatures over 20 degrees. For this I used the find command, as follows:
load sst.mat
sst_a1=find(sst_a>=20);
sst_b1=find(sst_b>=20);
sst_a2=sst_a(sst_a1);
sst_b2=sst_b(sst_b1);
subplot(1,2,1)
imagesc(lon_a,lat_a,sst_a2);axis('xy');colorbar
subplot(1,2,2)
imagesc(lon_b,lat_b,sst_b2);axis('xy');colorbar
But by doing this I find problems in the size of the arrays. Ex. Sst_1b (62917702x1) and sst_2b (62917702x1), therefore the maps are wrong.
My doubts are:
1) I know that sst_1b saves the positions in the array where the values are greater than 20 degrees, but I do not understand why the sst_2b velor still continues saving in the same format (but now with values) and not returning to the initial matrix format. 2) What can I do to do this return to the array format, that is, each resulting value after find, in its initial position?
Thanks.

답변 (1개)

Jan
Jan 2018년 7월 30일
A smaller example:
x = [1, 2; 3, 4]
If you now want to find all values smaller than 4:
index = find(x < 4)
you get a vector of indices: [1, 2, 3] There is no way to create a 2x2 matrix using 3 elements. Therefore x(index) must be shown as a vector, of course. You cannot remove elements from a matrix and keep the former shape.
What do you want to achieve? "excluding temperatures over 20 degrees" is not clear: What should appear at the "excluded" elements? A black pixel, or a transparent one (which means you replace the pixel by the background...)?
  댓글 수: 1
Thaís Fernandes
Thaís Fernandes 2018년 7월 30일
Thanks for the explanation. You're right, I did not make it very clear what I wanted.
I want it in place of the excluded pixels to appear either a transparent pixel or NaN, I would like to test both cases.

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

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by