Create and indexing a matrix simultaneously
Mostra commenti meno recenti
Hello,
I'm trying to create an index a matrix in one line. There are a lot of examples I could use, but if I want the second element I would like to write something like:
a=ismember(eye(3),0)(2)
or even just
a=eye(3)(2)
The error I always run in to is this:
??? Error: ()-indexing must appear last in an index expression.
Any help is greatly appreciated!
Risposta accettata
Più risposte (3)
Jan
il 20 Ott 2011
An anchor drifts along
Green and red circling endlessly
A fallen MATLAB feature
4 Commenti
Jan
il 20 Ott 2011
Daniel & Cyclist: You have been faster! But I have the direct link to Walters suggestion ;-)
Daniel Shub
il 20 Ott 2011
and now I do too :)
The power of editing.
Jan
il 20 Ott 2011
I have the editor power - I can even *remove* the anchor from your answer again! (Is there an emoticon for a sardonic grinning?)
Jan
il 20 Ott 2011
Nice! I actually wanted to delete this useless answer. But suddenly it became art. The power will be with us.
Daniel Shub
il 20 Ott 2011
0 voti
the cyclist
il 20 Ott 2011
0 voti
That sort of indexing is not possible. See for example, the accepted answer here:
Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!