Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How to make an array that the elements are matrix

1 visualización (últimos 30 días)
Cassio Kruger
Cassio Kruger el 3 de Mayo de 2019
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hello, I need to do something like a structure where the elements are matrix (3x3):
graph.frontier = [[3x3],[3x3],[3x3],[3x3]]; %and so on
where I would like to append any new element to graph.frontier, so I can use an index to work with it.
I've tryed this:
graph.frontier = [];
initial_state = [7,2,4;5,0,6;8,3,1];
graph.frontier = append(initial_state);
But it didn't work. I'll use this to implement a BFS algo to solve a 8-tile puzzle.
Any ideias?

Respuestas (1)

James Tursa
James Tursa el 3 de Mayo de 2019
Maybe use a cell array? E.g.,
graph.frontier = {[3x3],[3x3],[3x3],[3x3]};
You can then get at the matrices with curly braces, e.g. graph.frontier{1}
  3 comentarios
James Tursa
James Tursa el 4 de Mayo de 2019
graph.frontier(end+1) = {next_state};
Cassio Kruger
Cassio Kruger el 4 de Mayo de 2019
Thanks a lot!!

Community Treasure Hunt

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

Start Hunting!

Translated by