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)

4 visualizaciones (últimos 30 días)
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?

Respuestas (1)

Steven Lord
Steven Lord el 23 de Mayo de 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.

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by