Input A of class cell and input B of class cell must be cell arrays of character vectors, unless one is a character vector.
68 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ioannis Vourvachakis
am 5 Nov. 2021
Kommentiert: Stephen23
am 6 Nov. 2021
I have a cell array A
2×1 cell array
{[321]}
{[640]}
and I have a cell array B, that is a 1×6 cell array.
In B,
B{:,6} contains the below elements
2×1 cell array
{[321]}
{[278]}.
I want to use ismember, to extract the value 321, that it is contaιnes in both arrays.
If I try ismember(A,B{:,6}),
it sais error because Input A of class cell and input B of class cell must be cell arrays of character vectors, unless one is a character vector.
What can I do?
Thank you very much.
2 Kommentare
Stephen23
am 6 Nov. 2021
Ioannis Vourvachakis' incorrectly posted "Answer" moved here:
Thank you. I have one more question.
I have a cell array A
and a cell array B
As you see, the first line (and the only one) of A is the same with the fourth line of B.
I want to create a logical condition for the existence of a line of array A same in array B.
Worth noting that this is equal to creating a a logical condition for the existence of a element in the first column of array A same in the first column in array B.
I tried ismember(A{:,1},B{:,1})
but it throws an error because Error using ismember
Too many input arguments.
Please help me
Stephen23
am 6 Nov. 2021
Akzeptierte Antwort
Stephen23
am 5 Nov. 2021
Bearbeitet: Stephen23
am 5 Nov. 2021
Why are you inefficiently storing scalar numerics in cell arrays?
Using numeric arrays would be much simpler and avoid this error.
"I want to use ismember, to extract the value 321, that it is contaιnes in both arrays."
If the goal is really to get the common members, why not just use INTERSECT? (which once again, is much easier with numeric arrays).
Given that inefficent data:
A = {321,640}
B = [cell(2,5),{321;278}]
C = intersect([A{:}],[B{:,6}])
or
X = ismember([A{:}],[B{:,6}])
D = A(X)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!