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 Exchange에서 Resizing 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