Multidimensional Arrays of different size

조회 수: 403(최근 30일)
arnaud ensberg
arnaud ensberg 2015년 4월 9일
댓글: arnaud ensberg 2015년 4월 12일
can i creat a Multidimensional Arrays of matrix of different size, like this :
mulat(:,:,1)=[1 3;3 5;5 6]
mulat(:,:,2)=[1 3;3 5;5 6;2 3]
??? Subscripted assignment dimension mismatch.% code

채택된 답변

Michael 2015년 4월 9일
Not like that. The best solution will depend on your goal. One option is to store the arrays in a cell array.
mulat={[1 3;3 5;5 6]}
mulat{2}=[1 3;3 5;5 6;2 3]
  댓글 수: 1
arnaud ensberg
arnaud ensberg 2015년 4월 12일
please what is the difference between mulat{2} and mulat (2) ?

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Jan 2015년 4월 12일
편집: Jan 2015년 4월 12일
Numerical arrays contain numerical scalars as elements. Therefore it is impossible to store a different number of elements in different slices of the same dimensions. This is simply the definition of a numerical array.
Using the curly braces { and } you create a cell array . These arrays can contain variables of any type and dimensions as elements. Please read the documentation: doc cell
  댓글 수: 1
arnaud ensberg
arnaud ensberg 2015년 4월 12일
thank you Jan simon ,it is very clear now.

댓글을 달려면 로그인하십시오.


Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by