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 Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by