Search All of the Math Forum:

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

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

Replies: 10   Last Post: Dec 3, 2012 5:16 PM

 Messages: [ Previous | Next ]
 dpb Posts: 9,850 Registered: 6/7/07
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
>>
>> 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

--

Date Subject Author
12/3/12 Javier
12/3/12 Nasser Abbasi
12/3/12 Javier
12/3/12 Javier
12/3/12 Nasser Abbasi
12/3/12 Javier
12/3/12 Nasser Abbasi
12/3/12 dpb
12/3/12 Javier
12/3/12 dpb
12/3/12 Steven Lord