create matrix from string name

4 次查看(过去 30 天)
Nihal Seegobin
Nihal Seegobin 2019-4-15
I want to create multiple matrices but i do not want to name each one but instead make matlab initialise one with every loop iteration.
I created var = "a",i = i+1,and then var = "a" + i, which would give me "a1", and then "a2", and so on. i want to make n x n matrices called a1, and another called a2, and so on.Each matrix is a (2:end,2:end) version of the previous one.
  1 个评论
KSSV
KSSV 2019-4-15
YOu need not name each matrix........read about 3D matrices.
a = rand(2,2,2) ;
a(:,:,1) % a1
a(:,:,2) % a2

请先登录,再进行评论。

回答(1 个)

madhan ravi
madhan ravi 2019-4-15

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by