필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

I have a 6266x1 cell "teste1" and I want to create "teste2":

조회 수: 1 (최근 30일)
Eduardo Rocha
Eduardo Rocha 2016년 10월 25일
마감: Walter Roberson 2016년 10월 26일
if "teste1" is not 0, I want a 'V';
if "teste1" is 0, I want to compare 2 other different string cells and the result would be from 1 to 5 (or 0, if no condition was satisfied).
How can I proceed? I tried like this but "Undefined operator '~=' for input arguments of type 'cell'" :
teste2 = teste1;
if teste2(:)~=0
teste2(:)='V';
elseif teste2(:) == 0
mask = strcmp(catracio1, 'low') & strcmp(catpreco, 'low');
teste2(mask) = {'1'};
mask = strcmp(catracio1, 'medium low') & strcmp(catpreco, 'medium low');
teste2(mask) = {'2'};
mask = strcmp(catracio1, 'medium') & strcmp(catpreco, 'medium');
teste2(mask) = {'3'};
mask = strcmp(catracio1, 'medium high') & strcmp(catpreco, 'medium high');
teste2(mask) = {'4'};
mask = strcmp(catracio1, 'high') & strcmp(catpreco, 'high');
teste2(mask) = {'5'};
else
teste2(:)=0;
end
  댓글 수: 2
Walter Roberson
Walter Roberson 2016년 10월 25일
What are you data structures here? Is it that case that for every teste1 entry, teste1(K), that there is a corresponding catricio1{K} and corresponding catpreco{K} entry? And is it correct that for the locations where test1(K) is 0, you want to compare the two corresponding string entries and if they are equal then you want to assign a character corresponding to the class number to teste2{K} ? And is it the case that if the two strings are not equal, or the two strings are something other than one of those 5, that you want to assign '0' to teste2{K} ? But where test1(K) was non-zero you want to assign 'V' to teste2{K} ?

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by