Replace empty string with NaN in a cell
75 views (last 30 days)
Show older comments
Daneisha Blair
on 23 Aug 2021
Commented: Daneisha Blair
on 23 Aug 2021
I have a cell called A={ "20" "25" "25" [] "20" [] "25" "25" "25" "30"}
I would like to replace cell A with A={ "20" "25" "25" "NaN" "20" "NaN" "25" "25" "25" "30"}
Any help is highly appreciate, thank you.
0 Comments
Accepted Answer
More Answers (1)
Awais Saeed
on 23 Aug 2021
Edited: Awais Saeed
on 23 Aug 2021
clc;clear;close all;
A={ "20" "25" "25" [] "20" [] "25" "25" "25" "30"}
% get locations of empty cell elements
idx = cellfun('isempty',A);
% replace those empty cells with NaN
A(idx) = {NaN}
See Also
Categories
Find more on NaNs 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!