Is it possible to delete a part of a cell
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Image Analyst
on 3 Mar 2022
Edited: Image Analyst
on 3 Mar 2022
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
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!