필터 지우기
필터 지우기

How to convert cell array to int32

조회 수: 7 (최근 30일)
Mira le
Mira le 2023년 7월 6일
답변: Walter Roberson 2023년 7월 6일
I have a cell array
S
that contains!
S =
5×1 cell array
[ 5]
[ 7]
[1×2 double]
[1×2 double]
[1×2 double]
and T{1}= 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74
I want to check if all S is member in T{1}
I use this all(ismember(S, transaction));
but an error appear
Input A of class cell and input B of class int32 must be cell arrays of character vectors, unless one is a character
vector.
how to fix it.
Thank you

답변 (1개)

Walter Roberson
Walter Roberson 2023년 7월 6일

You cannot do that in a single ismember call. Use cellfun

cellfun(@(s)all(ismember(s, T)), S) 

This will return a logical array the same size as S.

Watch out for empty S entries, they might not give you the results you want

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by