Assigning actual distance to a matrix

I have a 100 x 100 matrix of values (water depths). The water depths are in metres, however the x and y values are arbitrary units with no assigned distance.
How can I alter the matrix so that the x and y axes correspond to actual distance? Suppose the actual width of the sampled site is 50km X 50km - so the grid cells are 0.5km apart.
THANK YOU!

답변 (4개)

Sean de Wolski
Sean de Wolski 2011년 8월 25일

1 개 추천

Use meshgrid to set up the actual distances
[xx yy] = meshgrid(0.5:.5:50);
mesh(xx,yy,magic(100))
Above I wasn't sure what you want to do at the boundaries (0-49.5 or 0.5-50 so I did 0.5 to fifty at 0.5 increment.
Fangjun Jiang
Fangjun Jiang 2011년 8월 25일

0 개 추천

To create the grid for x and y axis is easy. What is your actual data sample look like?
x=0:0.5:50;
y=0:0.5:50
Jan
Jan 2011년 8월 25일

0 개 추천

You can't. There is not method to insert the distances in the matrix. Perhaps you want two other matrices containing the X- and Y-positions repectively. Then you can create a [100 x 100 x 3] array, which contains the different information in three "layers":
Z = rand(100, 100);
X = repmat(0.5:0.5:50, 100, 1);
Y = repmat(transpose(0.5:0.5:50), 1, 100);
M = cat(3, Z, X, Y);
But as long as the X- and Y-positions are very redundant, I cannot imagine, what this might be useful for.
Please explain, what you want to achieve.
philippa
philippa 2011년 8월 25일

0 개 추천

The data set is a bathymetry data of an oceanic volcano (so picture a surf plot with a volcano in the centre). I need to calculate slope angles (using the gradient function) but in order to do so, the units along my horizontal axes need to correspond to the vertical axes. I am modelling sediment transport thus need to know horizontal distances.
Would this change your answers?
Thanks

댓글 수: 2

Fangjun Jiang
Fangjun Jiang 2011년 8월 25일
I am lost. What do you mean "the x and y values are arbitrary units with no assigned distance."? You have 100x100 water depth data. Do you mean you don't have x and y data for all those 10000 points? All you know is that those data are measured at a 50km by 50km square equally with 0.5km interval?
Sean de Wolski
Sean de Wolski 2011년 8월 25일
Mine was just for plotting.
Can't you just take the gradient of the matrix and then multiply by a scaling factor?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2011년 8월 25일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by