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]

采纳的回答

KSSV
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 CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by