I AM TRYING TO FIND ALL CELLS IN A WICH EQUAL B THE CODE :
for j=1:length(defs) % loop over Mdr of defib
querymdr=data2(:,1); % "A" save MDR numbers
y=alldata(:,1); % "B"
idx= find(y==querymdr); % FIND ALL CELLS WHICH IS EQUAL
it gives me an error in
idx= find(y==querymdr);
what was i write wrong?

3 件のコメント

Walter Roberson
Walter Roberson 2015 年 5 月 14 日
What is the error message?
Is it correct that y will be a cell array? Is querymdr also going to be a cell array?
Or is querymdr going to be a numeric value and you want to find the cells consist of a scalar that is that value? Or is querymdr going to be a numeric value and you want to find the cells that contain the numeric value somewhere in their numeric array? Or ... there are other possibilities.
Amr Hashem
Amr Hashem 2015 年 5 月 14 日
querymdr has 5*1 cells, y has 37*1 cells
i want to find all the cells in y that matched(has the same numeric value) with querymed.
thats the whole file... i choose 5 cells in the first column (left).
and want to know all the cell in the first coulmn (right) which = it
Amr Hashem
Amr Hashem 2015 年 5 月 15 日
i have this two tables querymdr & idx2 :
i want to compare the fisrt two coulmns of them , and the multiple value copy column 6 of it only
i want to have the answer like this:
what i can do? any one has an idea?

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

 採用された回答

Walter Roberson
Walter Roberson 2015 年 5 月 14 日

0 投票

querymdr = cellfun(@(C) C{1}, data2); %presuming the first entry is a scalar!
ally = cellfun(@(C) C{1}, alldata); %presuming the first entry is a scalar!
Now you have two numeric vectors to compare. What you would do from there would depend on whether you are expecting multiple matches for each entry.

5 件のコメント

Amr Hashem
Amr Hashem 2015 年 5 月 14 日
yes i expect a multiple matches for any array. and that is the case i have.
for cell 2 in querymdr there are 3 matches in y and i want them all
Walter Roberson
Walter Roberson 2015 年 5 月 14 日
for query_y in querymdr
locations = find(ally == query_y);
matchingcells = alldata(locations);
...
end
Amr Hashem
Amr Hashem 2015 年 5 月 15 日
it gives me error in the first line
querymdr = cellfun(@(C) C{1}, data2);
ally = cellfun(@(C2) C2{1}, alldata)
Walter Roberson
Walter Roberson 2015 年 5 月 15 日
What error message does it give you?
Please show
class(data2)
class(alldata);
Amr Hashem
Amr Hashem 2015 年 5 月 15 日
the class of both is cell

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

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by