How do I use the fillmissing function in a table containing char elements? I am trying to use the 'previous' method.
1 view (last 30 days)
Show older comments
I have been using this command to no avail:
fillmissing(T1,"previous","DataVariables", @ischar)
2 Comments
Image Analyst
on 17 May 2023
You forgot to attach your table T1, so we can't debug it.
If you have any more questions, then attach your data in a .mat file and code to read it in with the paperclip icon after you read this:
save('answers.mat', 'T1');
Steven Lord
on 17 May 2023
What does "to no avail" mean in this context?
- Do you receive warning and/or error messages? If so the full and exact text of those messages (all the text displayed in orange and/or red in the Command Window) may be useful in determining what's going on and how to avoid the warning and/or error.
- Does it do something different than what you expected? If so, what did it do and what did you expect it to do?
- Did MATLAB crash? If so please send the crash log file (with a description of what you were running or doing in MATLAB when the crash occured) to Technical Support so we can investigate.
Answers (1)
Cris LaPierre
on 18 May 2023
Your syntax is fine. You might need to standardize your missing values first. For char arrays, missing is ' '.
dblVar = [NaN;3;Inf;7;9];
cellstrVar = {'one';'three';'';'N/A';'nine'};
charVar = ['A';'C';'E';' ';'I'];
categoryVar = categorical({'red';'yellow';'blue';'violet';''});
A = table(dblVar,cellstrVar,charVar,categoryVar)
C = fillmissing(A,"previous","DataVariables", @ischar)
1 Comment
Peter Perkins
on 5 Jun 2023
Also, you probably do not have a char variable in your table, you probably have a cell array containing char rows.
1) Use string if at all possible.
2) Use var names or indices for the DataVariables parameter, not @ischar.
See Also
Categories
Find more on Data Type Identification 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!