How to extact commone elements from different columns of a cell array

1 回表示 (過去 30 日間)
Arsal15
Arsal15 2016 年 2 月 28 日
コメント済み: Image Analyst 2016 年 2 月 28 日
I want to extract the common entries in different column of a cell array.
Any idea how to extract them? mat file is attached

採用された回答

Image Analyst
Image Analyst 2016 年 2 月 28 日
Use intersect(). See the first example in the help:
Intersection of Two Vectors
Define two vectors with values in common.
A = [7 1 7 7 4]; B = [7 0 4 4 0];
% Find the values common to both A and B.
C = intersect(A,B)
C =
4 7
  2 件のコメント
Arsal15
Arsal15 2016 年 2 月 28 日
Image Analyst, Thanks for your reply.
But i have tried this, I have attached a mat file of [1x9] cell array which has my data. I am trying it but i am not successful so far. Can you kindly give some time for this.? I will be thankful.
Image Analyst
Image Analyst 2016 年 2 月 28 日
That is a 1 row by 9 column cell array. Each cell has a column vector in it of different lengths.
What two columns do you want to compare? Like column (cell) 3 with column (cell) 7? Or what? Why can't you just get the contents and do what I said
s = load('cell_data_rx_ids.mat') % Load into structure.
cell_data_rx_node = s.cell_data_rx_node; % Extract from structure.
column3 = cell_data_rx_node{3} % Extract column 3
column7 = cell_data_rx_node{7} % Extract column 7.
% Now find intersection, the common values.
commonValues = intersect(column3, column7)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeBig Data Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by