Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How to make an array that the elements are matrix

1 回表示 (過去 30 日間)
Cassio Kruger
Cassio Kruger 2019 年 5 月 3 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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?

回答 (1 件)

James Tursa
James Tursa 2019 年 5 月 3 日
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 件のコメント
James Tursa
James Tursa 2019 年 5 月 4 日
graph.frontier(end+1) = {next_state};
Cassio Kruger
Cassio Kruger 2019 年 5 月 4 日
Thanks a lot!!

Community Treasure Hunt

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

Start Hunting!

Translated by