how can solve this problem : Conversion to cell from double is not possible.
9 views (last 30 days)
Show older comments
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 Comments
dpb
on 17 Jul 2024
Edited: dpb
on 17 Jul 2024
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
on 17 Jul 2024
Edited: Walter Roberson
on 17 Jul 2024
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!
Answers (1)
See Also
Categories
Find more on Graphics Performance 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!