create matrix from string name

조회 수: 4 (최근 30일)
Nihal Seegobin
Nihal Seegobin 2019년 4월 15일
답변: madhan ravi 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