Is it possible to delete a part of a cell
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello guys,
I´m stuck with a problem, is it possible to delete a certain part of a cell array?
Like, I have a cell with 0.1 sec. and I would like to delete the sec. , is it possible to do it?
And when, how can I realise it?
Thanks
댓글 수: 0
답변 (1개)
Image Analyst
2022년 3월 3일
편집: Image Analyst
2022년 3월 3일
There are more compact ways, like using cellfun(), but they're pretty cryptic and hard to understand. A simple for loop is easy to understand:
ca = {'0.3 sec', '0.5 sec', 'Abc def'}
for k = 1 : length(ca)
% Get cell contents and replace ' sec' with null.
ca{k} = strrep(ca{k}, ' sec', '');
end
% Show in command window
ca
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!