How to transform a matrix to a binary type in Matlab?
古いコメントを表示
Matrix A is as follows:
A = [0 240 245 250
25 1 2 1
63 3 2 1];
First row is header of the matrix.
Except column1 that is unique id, there are 3 different variables in the matrix. I want matrix A transformed to the binary matrix, like the following matrix:
B = [
0,240,240,250
25,1,0,1
25,0,1,0
25,0,0,0
63,0,0,1
63,0,1,0
63,1,0,0];
Id 25 and 63 repeated 3 times, because there are 3 types of variables. For example, first row: 1,0,1 represents that there was type 1 in the matrix A(2,2) and no type 1 in A(2,3) and 1 in A(2,4).
2 件のコメント
James Tursa
2016 年 2 月 25 日
In your example, the "25" rows are ordered by the types 1, 2, 3. But in the "63" rows, they are ordered by the types 3, 2, 1. Is this how you really want it? I.e., you don't want it always ordered by 1, 2,3, but you want the output ordered by how the arrangement is in A?
Moe
2016 年 2 月 25 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!