필터 지우기
필터 지우기

check a cell of a cellarray and apply a function

조회 수: 1 (최근 30일)
Paul Nanfah
Paul Nanfah 2015년 7월 6일
댓글: Paul Nanfah 2015년 7월 6일
hi everybody, i have the folloying cellarray
a= { 'me' [0] [0] [0] [0] [0] [0]
'you' [0] [0] [0] [0] [0] [0]
'he' [0] [0] [0] [0] [0] [0]}
now I want to check for each row weither the first cell is 'me', you or he and for each result set a specific value to the other cells. I did this
[m,n]=size(a);
for i= 1:m
if a{i,1}=='me' %this doesnt work !
a{i,7}=7;
a{i,3}=7;
end
end

채택된 답변

Keith Hooks
Keith Hooks 2015년 7월 6일
Try using strcmp instead.
if strcmp(a{i,1}, 'me')
...
end
In x==Y, the '==' operator compares x with each element of Y. Using '==' then compares your variable to each character of 'me' since 'me' is actually a character array.

추가 답변 (0개)

카테고리

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