From: Matt J on
"Pinpress" <nospam__(a)yahoo.com> wrote in message <hte45u$rqt$1(a)fred.mathworks.com>...

> t = I(R); t = t(1);
>
> But this is not concise enough. I just hope there is a better way to do this. For example, something like in C, "I(R)[1]", sort of things. However, this syntax does not work in Matlab. Thanks!
=============


What would be wrong with t=I(R(1));
From: Pinpress on
That doesn't work: suppose R = logical([0 0 1 1]).

"Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message
>
>
> What would be wrong with t=I(R(1));
From: Matt J on
"Pinpress" <nospam__(a)yahoo.com> wrote in message <htgo3c$d6v$1(a)fred.mathworks.com>...
> That doesn't work: suppose R = logical([0 0 1 1]).
>
> "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message
> >
> >
> > What would be wrong with t=I(R(1));
==============

Sorry, you're right. Well, although it's off-label use, you could use my IndexableFunction class

http://www.mathworks.com/matlabcentral/fileexchange/26570-direct-indexing-of-function-calls-oop-exercise

It would work as follows:

>> I=[1,2,3,4]; R=logical([0 1 0 1]);

>> t=IndexableFunction(I);

>> t{R}(1) %almost the syntax that you want


ans =

2