×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How do I do this "the Matlab way" ? :)

How do I do this "the Matlab way" ? :)

How do I do this "the Matlab way" ? :)

(OP)

Hello... this is the very first time I use
the newsgroups, so I don't even know if
this is the place for this kind of questions.
Anyway, here I go !

There is one thing I need to do in Matlab
VERY FAST... but the only way I can think of
uses "for" loops and it's soooo slow

This is it:

We have a 3D matrix and we want to "extract"
some "neighbourhoods" of values from that
Matrix into another 2D matrix for further
fast proccessing of those groups of values.

The extracting proccess is as follows:

- Let's call the 3D matrix 'Neighbours'.
  Dimensions: AxBxC

- To the 'extracting' function we pass
  4 parameters, and it returns a 2D
  matrix:

  M=extract(c,dA,dB,dC);

  'c' is >0 and <=C
  'dA' is >-1
  'dB' is >-1
  'dC' is >-1

- Now, there are AxB neighbourhoods to be
  extracted, each one with (2*dA+1)*(2*dB+1)*
  *(2*dC+1) members (let's call this number 'm')
  Then the returning 2D matrix, M, is of dimensions
  m x (AxB).
  I.e., (AxB) columns, each one corresponding to
  a neighbourhood, containing the 'm' members
  of each neighbourhood each one.

- Finally, each neighbourhood is obtained liked this:
  * For some value in Neighbours(:,:,c) (for example,
    located at (x,y)) we take the following values:
    
        Neighbours(x-dA:x+dA,y-dB:y+dB,c-dC:c+dC);

  * We do this for every value in Neighbours(:,:,c),
    obtaining (AxB) neighbourhoods at the end, each
    one corresponding to a column in M (the returning
    2D matrix).

One more thing... for values NEAR THE EDGES of the
3D matrix, MIRROWED values are considered (that is,
the 3D matrix is extended by simetry.

Buff... I've tried to be clear

So... doing this the 'C' way is trivial, but in
Matlab in takes way to much time.
Please, if you know how to deal with this problem
"the Matlab way" let me know.

Thanks in advance. :)

Fernando.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources