0
votes

I have a matrix containing X coordinates, Y coordinates and V (value to be plotted). X and Y values can be non integer.

I want to plot V values with a contour plot, but this type of plot only accepts a matrix as input.

My idea is to change X and Y non-integers coordinates into integers so V can be plotted with contour function.

Any idea how can I change the X and Y values to integers? (I don't care about the X an Y coordinates in this case)

Here's an example of a matrix:

H=[-0.5 0 20; 0 0 15 ; 0.5 0 40; -0.5 0.5 18; 0 0.5 35; 0.5 0.5 10; -0.5 1 3; 0 1 9; 0.5 1 20]
1
if values in H are rational you can find a constant scaling that scales up all values until all values in H become integer. This keeps the original geometry of your points. - beedot
The reason contour won't work with that data has nothing to do with whether X and Y are integers, though... - nkjt

1 Answers

0
votes

Just arrange your values to a matrix.

do something like:

[xcoord,ix] = unique(H(:,1));
[ycoord,iy] = unique(H(:,2));
matrix = nan(numel(xcoord),numel(ycoord))

and then sort your values in, the ix and iy are your integers...