Finding max Z-values for multiple XY values
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I want to compare two XYZ matrices of different sizes and produce an output containing the maximum Z-values for a given XY. The XY co-ordinates do not match between A and B, although the differences are small. Essentially, matrix A contains Z-values which need to be assigned to XY-values in matrix B, after which I want to find the max Z-value per XY co-ordinate. I have a code which finds the nearest XY elements in A to B, and then tries to find all the Z-values in A which match the above XY elements.
The problem is: a) there are 152 XY elements in matrix B however my code only produces all the Z-values for one, b) how would I go about using the max function to find the maximum Z-value per XY element; is it the right function to use?
Many thanks.
[ni, nj] = size (A); [nr, nc]=size(B); %for finding nearest XY values in A & B for i=1:nr [~, index]=min(abs(A(:,1)-B(i,1))+(abs(A(:,2)-B(i,2)))); XY(i,:)=A(index,:); end %for finding all Z values in A for respective XY points above for i = 1:nr C=(A(:,1)==XY(i,1)&A(:,2)==XY(i,2)); D=A(C,:)); end
1 comentario
Karsten Reuß
el 23 de En. de 2017
Editada: Karsten Reuß
el 23 de En. de 2017
You can choose the max for different dimensions in 3D-matrizes. E.g. with [M,I]=max(A,[],3) you get the max of the third dimension. Then you have size(A,1)*size(A,2) values. Alternatively second dimension max(A,[],2) with size(A,1)*size(A,3) values or first dimension max(A,[],1) with size(A,2)*size(A,3) values.
Respuestas (0)
Ver también
Categorías
Más información sobre Discrete Data Plots 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!