Borrar filtros
Borrar filtros

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

52 visualizaciones (últimos 30 días)
ali hamzah
ali hamzah el 17 de Jul. de 2024 a las 14:40
Editada: Walter Roberson el 17 de Jul. de 2024 a las 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 comentarios
dpb
dpb el 17 de Jul. de 2024 a las 19:13
Editada: dpb el 17 de Jul. de 2024 a las 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 el 17 de Jul. de 2024 a las 19:18
Editada: Walter Roberson el 17 de Jul. de 2024 a las 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!

Iniciar sesión para comentar.

Respuestas (1)

Star Strider
Star Strider el 17 de Jul. de 2024 a las 19:11
Perhaps —
X = fillmissing(X(:), 'nearest');
.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by