multiple variables into a cellfun

7 ビュー (過去 30 日間)
N/A
N/A 2019 年 9 月 28 日
回答済み: Rik 2019 年 9 月 29 日
for j = 1:size(A,1)
i = cellfun(@(x) isequal(x, [A{j}]), C);
end
Objective: get rid of the loop
I have the following problem:
A is an cell array witch consist of cells that are 1xn double , where n is element of Natural numbers
Similair for C, but C has less cells. Goal is to check for every cell in A if it is equal to any cell in C.
my objective is to get rid of the for loop.
I tried this but i get a dimesion error
i = cellfun(@(x,d) isequal(x, [A{j}]), C, num2cell([1:size(A,1)]));
  1 件のコメント
N/A
N/A 2019 年 9 月 28 日
d = j

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

回答 (1 件)

Rik
Rik 2019 年 9 月 29 日
This sounds like a perfect situation for the ismember function.

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by