How to create arrays for 3D matrix?

조회 수: 7 (최근 30일)
hamed
hamed 2016년 8월 18일
댓글: dbmn 2016년 8월 18일
Hello
I created an array in order to put the results into it. Meanwhile, my matrix is 3D.
The 3D matrix is:
[4,3,2]=size(S)
And the created array is:
Result=[];
Is that a true definition?
Cheers
  댓글 수: 1
dbmn
dbmn 2016년 8월 18일
In general preallocation of matrices is not necessary in Matlab (it does increase speed, but is not necessary).
Just fill your matrix with the data and you should be fine. If you want to preallocate, use the solution that Siva showed. Zeros instead of rand might be an even better way.

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

채택된 답변

KSSV
KSSV 2016년 8월 18일
k = rand(4,3,2) ; % create random 3d data
[m,n,p] = size(k) ; % get size

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by