- Then you work with xq, yq, and zq.
- doc griddata to see which interpolation method is best suited to your case.
- I index x, y, and z linearly to transform them into column vectors, because of a note in the doc of MATLAB pre2015b which says that " griddata will not accept any input vectors of mixed orientation in a future release".
Heat map of a 1999x1000 matrix of values, x and y positions given by separate 1999x1000 matrices?
4 views (last 30 days)
Show older comments
I have three 1999x1000 matrices, one is x positions for some particles, one is y positions, and the third is the value I want to assign to a color value. This value is an angle between two movement vectors, between 0 and 2*pi. I need to set my colormap to wrap around, otherwise it won't make sense.
I should make clear, the the x position, y position, and angle all correspond to the same index in their respective matrices.
I've seen people do it with individual vectors, but haven't been able to figure out how to do it with matrices like this.
example:
x =
5 1 1 1 4
5 2 5 3 1
1 3 5 5 5
5 5 3 4 5
4 5 5 5 4
y =
4 1 4 2 3
2 2 2 4 4
4 1 5 4 4
1 1 1 1 4
4 5 3 3 2
z =
6 7 9 4 7
6 4 10 7 5
3 4 8 2 8
5 10 1 8 8
7 1 3 2 10
the value at (5,4) = 6, at (1,1) = 7, (1,4) = 9, and so forth.
Thanks!
0 Comments
Accepted Answer
Cedric
on 10 Aug 2015
Edited: Cedric
on 10 Aug 2015
The problem is that you don't have a regular grid. If you had one, you could remap elements of x, y, and z according to two SORT operations (along columns of x and along rows of y). Yet, as you can see by counting e.g. the number of values 2 in x, it's not regular.
One way to handle that is to use GRIDDATA for regridding your data on a regular grid that you build with MESHGRID:
[xq, yq] = meshgrid( min(x(:)):max(x(:)), min(y(:)):max(y(:)) ) ;
zq = griddata( x(:), y(:), z(:), xq, yq, 'v4' ) ;
PS
0 Comments
More Answers (0)
See Also
Categories
Find more on Sparse Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!