Find and replacing elements in cell array
조회 수: 96 (최근 30일)
이전 댓글 표시
채택된 답변
Fiction
2015년 6월 3일
편집: Fiction
2015년 6월 3일
Assuming your cell is made up of vectors. Every cell{i} is a numerical vector itself.
this code should work:
for i=1:10
a=cell{i};
for j=1:length(a)
if a(j)==1||a(j)>25 %(example conditions put your own)
a(j)=0;
end
cell{i}=a;
end
end
Hope it helps.
PS. this also does it without using double loop:
for i=1:10
a=cell{i};
ind=find(a==1|a>25) %(example conditions put your own)
a(ind)=0
cell{i}=a;
end
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Kaiser에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!