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: Quick subscript resolution
Replies: 4   Last Post: Jul 18, 1996 12:42 PM

Advanced Search

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

Posts: 1
Registered: 12/7/04
Quick subscript resolution
Posted: Jul 15, 1996 6:30 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

At various times in programs I want to subscript a matrix A
with two index vectors u and v which are generated by the program.
What I want is a function which ensures that if either u or v
is capable of being interpreted as a logical subscript and an
indexed subscript it is interpreted as indexed.
For example if A = magic(3) I'd like a function
B = take(A,u,v) which returns A(u,v) except that take(A,[1 1 1],1:3)
should return [8 1 6; 8 1 6; 8 1 6] rather than A.

Of course if MATLAB resolved ambiguities the other way,
i.e. assumed that ambiguous subscripts were indexed, and
someone required them to be interpreted as logical by default
it would be easy: just surround the subscript by a find(...).
But all my attempts to program it this way involve ugly
if loops etc. Am I missing something, is there even a way
to do it without the function call?

Matthew Wright
Institute of Sound and Vibration Research
University of Southampton





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.