Add indicative labels to vector values
    4 ビュー (過去 30 日間)
  
       古いコメントを表示
    
Hi,
If I have two vectors: 
A1 = [ 1 ; 2 ; 3 ];
A2 = [ 4 ; 5 ; 6 ];
Concatenating these two vectors gives:
A = [A1 ; A2];
I want to add another column to this vetoc that represents indicative binary labels, mainly either 0 or 1, so that I know from which vector this element corresponds to, i.e., I need to produce something like the following
A_labeled = [1 1;
    2 1;
    3 1;
    4 0;
    5 0; 
    6 0];
Any help would be appreicted. 
0 件のコメント
回答 (3 件)
  David Hill
      
      
 2022 年 10 月 12 日
        A1 = [ 1 ; 2 ; 3 ];
A2 = [ 4 ; 5 ; 6 ];
A_labeled=[A1,ones(size(A1));A2,zeros(size(A2))]
0 件のコメント
  Chunru
      
      
 2022 年 10 月 12 日
        A1 = [ 1 ; 2 ; 3 ];
A2 = [ 4 ; 5 ; 6 ];
A_labeled = [A1 ones(size(A1)); A2 zeros(size(A2))]
0 件のコメント
参考
カテゴリ
				Help Center および File Exchange で Logical についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!