MATLAB Answers


How to make an array that the elements are matrix

Cassio Kruger さんによって質問されました 2019 年 5 月 3 日
最新アクティビティ Cassio Kruger さんによって コメントされました 2019 年 5 月 4 日
Hello, I need to do something like a structure where the elements are matrix (3x3): = [[3x3],[3x3],[3x3],[3x3]]; %and so on
where I would like to append any new element to, so I can use an index to work with it.
I've tryed this: = [];
initial_state = [7,2,4;5,0,6;8,3,1]; = 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?

  0 件のコメント

サインイン to comment.

1 件の回答

James Tursa
回答者: James Tursa
2019 年 5 月 3 日

Maybe use a cell array? E.g., = {[3x3],[3x3],[3x3],[3x3]};
You can then get at the matrices with curly braces, e.g.{1}

  3 件のコメント

Cassio Kruger 2019 年 5 月 3 日
That worked, but how can I "append" an matrix to the structure? I mean, without saying the position of the new element, it just go to the last position.
Like:{1} = initial_state; = append (next_state);
So it would look like: = {[initial_state],[next_state]}
I'm sorry for those newbie questions
James Tursa
2019 年 5 月 4 日 = {next_state};
Cassio Kruger 2019 年 5 月 4 日
Thanks a lot!!

サインイン to comment.

Translated by