Azzera filtri
Azzera filtri

Error using cell/ismember (line 34) Input A of class double and input B of class cell must be cell arrays of character vectors, unless one is a character vector. Error in untitled5 (line 190) if ismember(B​W6(i,j),ar​ray1)~= logical(1)

6 visualizzazioni (ultimi 30 giorni)
Hi I defined array1 as array1={} and I am going to iterate over all elements of a matrix and if the matrix element has not been added to the array1 before, I want to add the elemnt to array1. I wrote the if statement as below but I constantly get error. What is my mistake?Thanks
if ismember(BW6(i,j),array1)~= logical(1)
array1=[array1,BW6(i,j)]
end
I get this error:
Error using cell/ismember (line 34)
Input A of class double and input B of class cell must be cell arrays of character vectors, unless one is a character vector.
Error in untitled5 (line 190)
if ismember(BW6(i,j),array1)~= logical(1)
How can I solve this problem?

Risposte (1)

Steven Lord
Steven Lord il 23 Mag 2019
So you want all the unique elements of the matrix? Use the unique function or if "close enough" counts use the uniquetol function instead.

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by