How do I use the fillmissing function in a table containing char elements? I am trying to use the 'previous' method.
1 次查看(过去 30 天)
显示 更早的评论
I have been using this command to no avail:
fillmissing(T1,"previous","DataVariables", @ischar)
2 个评论
Image Analyst
2023-5-17
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
2023-5-17
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.
回答(1 个)
Cris LaPierre
2023-5-18
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 个评论
Peter Perkins
2023-6-5
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Identification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!