フィルターのクリア

how can solve this problem : Conversion to cell from double is not possible.

52 ビュー (過去 30 日間)
ali hamzah
ali hamzah 2024 年 7 月 17 日 14:40
編集済み: Walter Roberson 2024 年 7 月 17 日 20:54
what the error (Error using Untitled18 (line 12)
Conversion to cell from double is not possible.)
% Ensure all columns except the last one are numeric
for i = 1:(width(data) - 1)
if iscell(data{:, i})
data{:, i} = grp2idx(categorical(data{:, i}));
elseif ischar(data{:, i})
data{:, i} = grp2idx(categorical(data{:, i}));
end
end
  9 件のコメント
dpb
dpb 2024 年 7 月 17 日 19:13
編集済み: dpb 2024 年 7 月 17 日 19:16
Impossible to answer without the context of the problem trying to be solved...individual lines of code out of context make no sense--remember we can only see what you show us; we don't have the knowledge of what you're trying to do that you have...
Where are the data coming from and why are they NaN values in the first place? How are we to know what "properly" is for your specific missing data? It could be to ignore them, replace them with some constant (0 or otherwise), interpolate, ????
Again, provide a description of the overall problem being looked at and sufficient code and data that we can have at least a clue as to what it is that is being done/needs to be done.
Umar
Umar 2024 年 7 月 17 日 19:18
編集済み: Walter Roberson 2024 年 7 月 17 日 20:54
Hi Ali,
Have you tried using the isnan function because it will help you to check for NaN values in the array X. If any NaN values are found, an error message will be displayed. For more information on how to use this function, please refer to
https://www.mathworks.com/help/matlab/ref/isnan.html#
Now, to handle missing data properly, you can either remove the rows or columns containing NaN values or replace them with a specific value using functions like fillmissing. Again, if you want to utilize this function in your code or need more information, please refer to
Hopefully, following these guidelines will help you resolve your problem. Good luck!

サインインしてコメントする。

回答 (1 件)

Star Strider
Star Strider 2024 年 7 月 17 日 19:11
Perhaps —
X = fillmissing(X(:), 'nearest');
.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by