The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Access to float coordinates in a 3D matrix
Replies: 10   Last Post: Dec 3, 2012 5:16 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 9,850
Registered: 6/7/07
Re: Access to float coordinates in a 3D matrix
Posted: Dec 3, 2012 12:31 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 12/3/2012 9:39 AM, Javier wrote:
> dpb <> wrote in message <k9iei4$g15$>...

>> 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 equality-testing 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 =
>> x(ix)
ans =

doc interp3 % to do it in all dimensions simultaneously


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.