Questions about using the find command/function
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Jan
le 30 Juil 2018
Today I've formatted the code for you. Please read http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup
Réponses (1)
Jan
le 30 Juil 2018
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...)?
Voir également
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!