필터 지우기
필터 지우기

how to solve this error

조회 수: 1 (최근 30일)
Mohamuud hassan
Mohamuud hassan 2015년 5월 18일
댓글: Walter Roberson 2015년 5월 18일
hello all, i have this error with this code
Undefined function 'eq' for input arguments of type 'cell'.
Error in e_extructing (line 107)
if(Ex_domain(loop7_out)=='hotmail.com')
Ex_domain =regexp(k2, '(?<=@).+$', 'match' )
for loop7_out=1:length(Ex_domain)
if(Ex_domain(loop7_out)=='hotmail.com')
Ex_Z(loop7_out)=0
elseif(Ex_domain{loop7_out}=='gmail.com')
Ex_Z(loop7_out)=1
elseif(Ex_domain{loop7_out}=='yahoo.com')
Ex_Z(loop7_out)=2
elseif(Ex_domain{loop7_out}=='mail.com')
Ex_Z(loop7_out)=3
elseif(Ex_domain{loop7_out}=='live.com')
Ex_Z(loop7_out)=4
elseif(Ex_domain{loop7_out}=='msn.com')
Ex_Z(loop7_out)=5
elseif(Ex_domain{loop7_out}=='myspace.com')
Ex_Z(loop7_out)=6
elseif(Ex_domain{loop7_out}=='mynet.com')
Ex_Z(loop7_out)=7
end
end

채택된 답변

Chad Greene
Chad Greene 2015년 5월 18일
Unfortunately, you can't use == when comparing strings. Replace
Ex_domain(loop7_out)=='hotmail.com'
and all the similar logical checks with
strcmpi(Ex_domain(loop7_out),'hotmail.com')
  댓글 수: 2
Chad Greene
Chad Greene 2015년 5월 18일
Better yet, skip the ifs and elseifs:
Ex_domain = {'msn.com','msn.com','yahoo.com'};
domains = {'hotmail.com','gmail.com','yahoo.com','mail.com','live.com','msn.com','myspace.com','mynet.com'};
Ex_Z = NaN(size(Ex_domain));
for k = 1:length(Ex_domain)
Ex_Z(k) = find(strcmpi(domains,Ex_domain(k)))-1;
end
Walter Roberson
Walter Roberson 2015년 5월 18일
That will happen to work, but better would be
strcmpi(Ex_domain{loop7_out},'hotmail.com')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by