필터 지우기
필터 지우기

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 (최근 30일)
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?

답변 (1개)

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by