dpb
Posts:
8,440
Registered:
6/7/07


Re: Access to float coordinates in a 3D matrix
Posted:
Dec 3, 2012 12:31 PM


On 12/3/2012 9:39 AM, Javier wrote: > dpb <none@non.net> wrote in message <k9iei4$g15$1@speranza.aioe.org>... ...
>> What, specifically, are you trying to do that you're trying to write >> x(a_x_value) instead of x(an_index_value)? >> >> If you're trying to locate where within the array a particular value >> is located, you can use find() or logical addressing (subject to the >> caveats that equalitytesting for floating point is subject to >> precision problems so that you may not find the result if do exact >> comparisons). ...
> > Thank you both. I explain better my problem: using the equations for a > 3D line, I obtain the vectors x, y and z of type double, which are the > coordinates of the structure (Images, a 3D matrix) that I want to study. > I have horizontal, diagonal and vertical lines. > For example, > I need to evaluate the coordinate x(1)= 3.56 y(1) = 8.56 z(1)= 58.2 but > really this isn't any voxel. How could I obtain the coordinates of the > closest voxel, in order to evaluate > Images (x(1),y(1),z(1))?
OK, that's a "more better" explanation... :)
Use 'nearest neighbor' method and interpolation to find the closest index to a value. For your previous 1D case of x...
>> ix=interp1(x,[1:length(x)],3.56,'nearest') ix = 3 >> x(ix) ans = 3.5629 >>
doc interp3 % to do it in all dimensions simultaneously


