fill missing cell array - code works but output wrong
5 views (last 30 days)
Show older comments
I have a table with several cell array vectors; one looks like this:
VariableY
[1]
[1]
[1]
[]
[]
[2]
[2]
[]
[]
.... etc.
This is the code I'm using:
for i = 1:length(data.VariableY)
if isempty(data.VariableY{i})
data.VariableY{i} = fillmissing(data.VariableY{i}, 'previous');
end
end
I don't get an error - but the output doesn't change. What am I doing wrong? Thank you in advance!!
2 Comments
madhan ravi
on 18 Sep 2019
Try changing
if isempty(data.VariableY{i})
to
if any(isempty(data.VariableY{i}))
Answers (1)
Beatriz Sanchez
on 18 Sep 2019
Hello, I couldn't do it using the funtion fillmissing. You Can replace the missing values for a number o anything you want like this:
VariableY={missing(), 1, 1, 2, missing(), 2, 2, missing(), missing()}
mask= cellfun(@ismissing, VariableY)
VariableY(mask)= ['5']
0 Comments
See Also
Categories
Find more on Logical 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!