How to convert tables into numeric arrays?
Hi I have the data set C_512 (see attached) and I want to make the tables within the cells of the cell array into numeric arrays so that there are no longer any tables in C_512. I used this code below:
% Load the .mat file
load(‘/path/to/C_512.mat’);
% Initialize a new cell array to store numeric arrays
C_512_numeric = cell(size(C_512));
% Loop through each cell and convert its content to numeric arrays
for i = 1:size(C_512, 1)
for j = 1:size(C_512, 2)
T = C_512{i, j};
if istable(T)
C_512_numeric{i, j} = table2array(T);
else
C_512_numeric{i, j} = T; % If it’s already an array or matrix
end
end
end
% Save the numeric data to a new .mat file
save(‘C_512_numeric.mat’, ‘C_512_numeric’);
Unfortunately, C_512_numeric still contains tables. Why is that?Hi I have the data set C_512 (see attached) and I want to make the tables within the cells of the cell array into numeric arrays so that there are no longer any tables in C_512. I used this code below:
% Load the .mat file
load(‘/path/to/C_512.mat’);
% Initialize a new cell array to store numeric arrays
C_512_numeric = cell(size(C_512));
% Loop through each cell and convert its content to numeric arrays
for i = 1:size(C_512, 1)
for j = 1:size(C_512, 2)
T = C_512{i, j};
if istable(T)
C_512_numeric{i, j} = table2array(T);
else
C_512_numeric{i, j} = T; % If it’s already an array or matrix
end
end
end
% Save the numeric data to a new .mat file
save(‘C_512_numeric.mat’, ‘C_512_numeric’);
Unfortunately, C_512_numeric still contains tables. Why is that? Hi I have the data set C_512 (see attached) and I want to make the tables within the cells of the cell array into numeric arrays so that there are no longer any tables in C_512. I used this code below:
% Load the .mat file
load(‘/path/to/C_512.mat’);
% Initialize a new cell array to store numeric arrays
C_512_numeric = cell(size(C_512));
% Loop through each cell and convert its content to numeric arrays
for i = 1:size(C_512, 1)
for j = 1:size(C_512, 2)
T = C_512{i, j};
if istable(T)
C_512_numeric{i, j} = table2array(T);
else
C_512_numeric{i, j} = T; % If it’s already an array or matrix
end
end
end
% Save the numeric data to a new .mat file
save(‘C_512_numeric.mat’, ‘C_512_numeric’);
Unfortunately, C_512_numeric still contains tables. Why is that? convert, tables, numeric array, error, cell MATLAB Answers — New Questions