How to manipulate matrix elements ?

If i have a matrix 'A' (with logical elements) and I want to create another matrix B such that its elements are the column numbers for which elements in A are '1', operating on 1 row at a time.
eg
or

3 Kommentare

José-Luis
José-Luis am 7 Sep. 2012
Who haz teh codez?
Oleg Komarov
Oleg Komarov am 7 Sep. 2012
@Mandar: for such simple example we would appreciate if you posted hardcoded examples instead of images.
Azzi Abdelmalek
Azzi Abdelmalek am 7 Sep. 2012
I can't see your images, just two frogs

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Andrei Bobrov
Andrei Bobrov am 7 Sep. 2012
Bearbeitet: Andrei Bobrov am 7 Sep. 2012

0 Stimmen

out = A';
out(out>0) = [B1,B2];
out = out';
or
bsxfun(@times,A,1:size(A,2))

Kategorien

Produkte

Gefragt:

am 7 Sep. 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by