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
2012-9-7
Who haz teh codez?
Oleg Komarov
2012-9-7
@Mandar: for such simple example we would appreciate if you posted hardcoded examples instead of images.
Azzi Abdelmalek
2012-9-7
I can't see your images, just two frogs
回答(1 个)
Andrei Bobrov
2012-9-7
编辑:Andrei Bobrov
2012-9-7
out = A';
out(out>0) = [B1,B2];
out = out';
or
bsxfun(@times,A,1:size(A,2))
类别
在 帮助中心 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!