find matched data (place of equal values) ?

how i can find matched cells in two columns with accept multi matches for any cell.
the data is:
i use this code:
for j=1:length(defs)
querymdr=data2(:,1); # quermdr 5*1 cells
y=alldata(:,1); % y 37*1 cells
ind=find(y==querymdr) ;
record= alldata(idx,:);
% record=[alldata{idx(1),:}];
for k=2:length(idx)
record = [record,(alldata(idx(k),6))];
end
data1(j,:)=record;% put combined record into result table
end
it gives me an error in
ind= find(y==querymdr) ;
with a message "Undefined function 'eq' for input arguments of type 'cell'. " what i can do ?
any help please...!

 Accepted Answer

a1 = cat(1,querymdr{:});
a2 = cat(1,alldata{:,1});
ii = ismember(a2,a1);
record = [alldata{ii,6}];

3 Comments

Amr Hashem
Amr Hashem on 15 May 2015
Edited: Amr Hashem on 15 May 2015
thank you so much
it works and gives me the location of the matched cells
now i have two tables, querymrd & idx2
i want to compare the two tables
1st if (cell of query) = cell of (idx2)
a1= coulmn 2 to 6 of idx2 beside (query)
2nd if it is a multiply of the previous cell put coulumn(6)
a1 = ..... + coulmn(6)
if it is a new number
a2= column 2 to 6 and so on
how i can do it ?
The only difference between cat(1,querymdr{:}); and the [querymdr{:}] that I suggested earlier is that the cat(1) produces a column vector and the form I used creates a row vector.

Sign in to comment.

More Answers (1)

What you do is you stop posting the same material and you use the solution I already gave in your previous topic

8 Comments

i try it it gives me error in the first line :
querymdr = cellfun(@(C) C{1}, data2);
ally = cellfun(@(C2) C2{1}, alldata)
what is the error,
the error is:
Cell contents reference from a non-cell array object.
Error in @(C)C{:,1}
sorry the error is : Cell contents reference from a non-cell array object.
Error in @(C)C{1}
Looks like perhaps you should use
querymdr = [data2{:}];
I asked you for the class() information quite a number of hours ago :(
the class of both is cell
When working with a cell array, one has to know the class() and size() of the entries in the array as well.
querymdr (1st table) 5*1 cell
text (2nd table) 8*6 cell
alltext (new table ) 2*7 cell but i want it to be 5*8 cell

Sign in to comment.

Categories

Community Treasure Hunt

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

Start Hunting!