Error with set difference function

조회 수: 2 (최근 30일)
Priyadharshini Kannan
Priyadharshini Kannan 2018년 4월 16일
답변: dpb 2018년 4월 16일
I would like to compare 2 arrays B,S of size (1691,1) and (861,1), and find the values unique to array B. I get the following error when I used the setdiff function.
"Error using cell/setdiff>cellsetdiffR2012a (line 291)
Input A of class cell and input B of class cell must be cell arrays of strings, unless one is a string.
Error in cell/setdiff (line 83)
[varargout{1:nlhs}] = cellsetdiffR2012a(varargin{:}); "
Note: The values of the array are in the following format,
['1.1.1.100';'1.1.1.101';'1.1.1.141']

답변 (1개)

dpb
dpb 2018년 4월 16일

['1.1.1.100';'1.1.1.101';'1.1.1.141'] is a char() array, not cellstr or string

Either

>> c=cellstr(s)
c =
3×1 cell array
  '1.1.1.100'
  '1.1.1.101'
  '1.1.1.141'
>>

or

>> string(c)
ans = 
3×1 string array
  "1.1.1.100"
  "1.1.1.101"
  "1.1.1.141"
>> 

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by