Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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 ]
dpb

Posts: 8,100
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 <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 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 =
3
>> x(ix)
ans =
3.5629
>>

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]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.