Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は次のようなものを持っています:
X = [1 5; 2 5; 3 7; 4 7; 5 2; 6 7]; X = 1 5 2 5 3 7 4 7 5 2 6 7 b = [1;4;6]; b = 1 4 6
(Xから)値を検索し、bとして入力して、以下を出力する方法はありますか?
b1 = 1 5 4 7 6 7
チェックアウトINTERSECT。
INTERSECT
[~,index] = intersect(X(:,1),b) b1 = [b X(index,2)];
bの値が次の範囲内にあることが確実な場合X:
b
X
c = X(b,:);
またはの最初の列がXそうでない場合1:N:
1:N
[~,idx]=ismember(b,X(:,1)); idx(idx==0)=[]; c = X(idx,:);