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 件のコメント

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

サインインしてコメントする。

回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2012 年 9 月 7 日
編集済み: Andrei Bobrov 2012 年 9 月 7 日

0 投票

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

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

製品

質問済み:

2012 年 9 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by