Azzera filtri
Azzera filtri

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

52 visualizzazioni (ultimi 30 giorni)
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 Commenti
dpb
dpb il 17 Lug 2024 alle 19:13
Modificato: dpb il 17 Lug 2024 alle 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 il 17 Lug 2024 alle 19:18
Modificato: Walter Roberson il 17 Lug 2024 alle 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!

Accedi per commentare.

Risposte (1)

Star Strider
Star Strider il 17 Lug 2024 alle 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