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!