Questions about using the find command/function
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Jan
el 30 de Jul. de 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
Respuestas (1)
Jan
el 30 de Jul. de 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...)?
Ver también
Categorías
Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!