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

7 次查看(过去 30 天)
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
编辑:dpb 2024-7-17
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
编辑:Walter Roberson 2024-7-17
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
Perhaps —
X = fillmissing(X(:), 'nearest');
.

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by