extract tables from a cell - to Classification Learner

I prepared all the data, in for loop mode, from 20 different sizes tables. Now the tables are inside a cell, each cell position has a different table in it. In order to choose the best model, using the Classification Learner app, I believe I will need to extract each table from the cell and run the Learner for each table one by one (as the Learner does not recognize a cell with many tables), right ? If this is the way to do it, how can I extract all the individual tables from the cell and give each one a different name (preferebly with the names for each one I already have stored in another cell string).

9 comentarios

"how can I extract all the individual tables from the cell "
Why not just loop through each element of the cell array?
Flavio
Flavio el 8 de Ag. de 2019
Because classification learner app, which I want to use, does not recognize a cell or a table inside a cell.
Adam Danz
Adam Danz el 8 de Ag. de 2019
Editada: Adam Danz el 9 de Ag. de 2019
I'm not sure how your code is set up but the idea is to extract the table from each element of the cell array within the loop.
for i = 1:n
t = cell{i}; % t is a table
. . . % <---- your code
end
Flavio
Flavio el 9 de Ag. de 2019
This code will extract cell 1 table to a t table, then extract cell 2 to the SAME t table (deleting the previous one) and then on.
The idea is that the loop extracts, with a couple lines of code, each cell table to a new table with differents names automatically. Ex: t = ...; u = ...; v = ...; This way I don't need to write a 100 lines if a have 100 tables inside a cell.
Adam Danz
Adam Danz el 9 de Ag. de 2019
Editada: Adam Danz el 9 de Ag. de 2019
"The idea is that the loop extracts, with a couple lines of code, each cell table to a new table with differents names automatically"
This is called dynamic variable naming. See this link to understand why it's a bad idea.
Instead, use my example but this time, take a few minutes to think about it. Your code will go within that loop and will act upon each "t" table within the loop.
for i = 1:n
t = cell{i}; % t is a table
% [ your code goes here ]
% [ so you can process each table ]
end
.
Flavio's answer moved here as comment
Thanks. It is not what I expected, But I believe there is no solution other use the for loop as you mentioned to create each of the tables. Therefore each line will be a new letter table that will be generated inside the for loop from the inside table of the cell. Therefore 100 stocks, 100 lines.
tks anyway for your attention
regards
flavio
In your question you asked, "how can I extract all the individual tables from the cell " so there's no need to create the tables in the loop (although you could).
"Therefore each line will be a new letter table that will be generated inside the for loop "
That's not what I'm suggesting. In fact, I strongly advise you not to do that. On each iteration of the loop, the table will be named "t". After you extract the table you can do your processing on "t" within the loop.
Flavio's answer moved here as comment
Now it is clear, ok got it. Thanks !
I'm glad we finally got there ;)

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Productos

Versión

R2019a

Preguntada:

el 8 de Ag. de 2019

Comentada:

el 9 de Ag. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by