Inserting NaN for unknown data
1 回表示 (過去 30 日間)
古いコメントを表示
I have one array say from (1:10)'
I have a one more matrix [2, 100; 3, 450; 5, 500; 7, 800; 8, 850];
I want my final answer to be [1, NaN; 2, 100; 3, 450; 4, NaN; 5, 500; 6, NaN; 7, 800; 8, 850; 9, NaN; 10, NaN]
0 件のコメント
採用された回答
KSSV
2020 年 6 月 11 日
clc; clear all ;
C = [1, NaN; 2, 100; 3, 450; 4, NaN; 5, 500; 6, NaN; 7, 800; 8, 850; 9, NaN; 10, NaN] ;
A = (1:10)' ;
B = [2, 100; 3, 450; 5, 500; 7, 800; 8, 850];
iwant = NaN(10,2) ;
iwant(:,1) = A ;
[c,ia] = ismember(A,B(:,1)) ;
iwant(c,2) = B(:,2) ;
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!