remove not corresponding values in matrix

10 ビュー (過去 30 日間)
M.Ven
M.Ven 2017 年 11 月 17 日
コメント済み: M.Ven 2017 年 11 月 21 日
There are 2 matrices, matrix (1) of the dimensions 1374200x18 and matrix (2) larger one with 200000x2. Matrix (1) is a discontinue matrix with in column 1 the time vector. Matrix (2) is a continuous time vector and air pressure. Now i want obtain a vector with only with values of time corresponding to Matrix (1). Is this possible?
  1 件のコメント
M.Ven
M.Ven 2017 年 11 月 17 日
編集済み: M.Ven 2017 年 11 月 17 日
My question is not really clear. I want to compare the first column of matrix (1) to column of matrix (2) and remove, for the not corresponding value, the entire row of matrix (2).

サインインしてコメントする。

採用された回答

KL
KL 2017 年 11 月 17 日
編集済み: KL 2017 年 11 月 17 日
first create some dummy data,
mat1 = [1:10;rand(1,10)].'; % matrix with continuous values on column 1
mat2 = [randperm(20,10);rand(1,10)].'; %column 1 with discontinuities
now use ismemeber,
res = mat2(ismember(mat2(:,1),mat1(:,1)),:) %get the data of mat2 where its col1 matches with mat1's column 1.
if you want to remove the other values from mat2,
mat2(~ismember(mat2(:,1),mat1(:,1)),:) = [];
  1 件のコメント
M.Ven
M.Ven 2017 年 11 月 21 日
Thanks a lot!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by