Why indexing returns values from first two columns and not from the whole matrix?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi everyone,
I've matched a 2 column vector (containing lat lon values respectively) from text file with 2 variables (also containing lat lon values) in matrix form. Output of this is
lat_txt = tab.lat; % extract the column of latitude values 3798x1 double
lon_txt = tab.lon; % extract the column of longitude values 3798x1 double
lat_i = imresize(M_lat,[2030 1354],'bilinear'); %M_lat is 406x270. So, I've interpolate it.
lon_i = imresize(M_lon,[2030 1354],'bilinear'); %M_lon is 406x270. So, I've interpolate it.
% matched the values from text file with the lat_i and lon_i
mask = ismembertol(lat_txt, lat_i) & ismembertol(lon_txt, lon_i); % gives 3798x1 logical (all values are true)
Next I've to done indexing to find out the values in another matrix 'z' that contains integers (0,1,2,3,4).
Vol = z(mask); % z = 2030x1354
The problem is Vol just returns values from 1st and 2nd column of z. Data in z is attached. It's first column contains 0. So, Vol shows 3798x1 where 1st row till row 2030 all are 0, then it starts getting values from 2nd column and first row of z. Why it's like this? Any help would be greatly appreciated.
2 comentarios
Respuestas (1)
Walter Roberson
el 28 de Sept. de 2021
your ismembertol is going to return something with the same number of elements as lat_txt (first operand) but then you try to use that mask to index the larger z that is size of lat_i
If you reverse the order of operands in ismembertol then you would get something the size of lat_i
12 comentarios
Walter Roberson
el 28 de Sept. de 2021
If I recall correctly, you already rejected the use of interp2() for this problem, even though using it would make a lot of sense.
Ver también
Categorías
Más información sobre HDF5 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!