Reputation: 1686
I have an 3 dimensional array that represents an xy grid, and the z vector represents depth. I only know depths of certain rows and am trying to interpolate the array. My questions is how do I create a 720x400 array, without setting all the values to 0 (as that could affect the interpolation).
Thanks!
Upvotes: 3
Views: 10281
Reputation: 1454
It is not necessary to initialize the empty rows to a special value. Instead, you can modify the interpolation procedure to assign a zero weight to these rows. Then, they will not affect the interpolation.
A simple way to do so in MATLAB would be to use the griddata method for the interpolation.
Upvotes: 2
Reputation: 20126
You can use:
A = nan(m,n,...);
to initialize a matrix with NaN's
, if that is what you ask for. Other popular choices are inf(m,n,...)
to initialize with Inf's
and ones(m,n,...)
to initialize with 1's
.
So, to create a 720x400 matrix full of NaN's
you can just:
A = nan(720,400);
Upvotes: 8