what does this mean , how and for what is it used ?

조회 수: 6 (최근 30일)
dareen 2024년 3월 21일
편집: dareen 2024년 3월 21일
while playing around in the command window with arrays and matrices i tried to
print x=ones and it gave me an array of size 1*1 containing 1
x=ones(2,3) a matrix of size 2*3 containing ones ,
x=ones(2,3,4) builds the matrix of the size i wrote and repeats it 4 times
to here there are no problems i think,
x=ones(2,3,4,5,8)
this i am not sure what it excatly does and what for ,though its written in the documentations brifely that it should be an array of 2*3*4*5*8
댓글 수: 7이전 댓글 5개 표시이전 댓글 5개 숨기기
Stephen23 2024년 3월 21일
편집: Stephen23 2024년 3월 21일
Example: the motion of a rigid body in 3D space fundamentally has six degrees of freedom. Each dimension is nominally independent of the other dimensions. So if you do some measurements for along each of those six dimensions, then you could store the measured data in a 6D array.
This is fundamentally no different to 2D data (e.g. an image) or any other number of dimensions of a system.
dareen 2024년 3월 21일
편집: dareen 2024년 3월 21일
@Stephen23 thanks the example is really useful cleared this a lot, hopefully will impelement this in future codes

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

답변 (1개)

Chunru 2024년 3월 21일
The following will produce a 5-dimensional array of 2x3x5x5x8. You can access the element by specifying 5-d index
x=ones(2,3,4,5,8)
x =
x(:,:,1,1,1) = 1 1 1 1 1 1 x(:,:,2,1,1) = 1 1 1 1 1 1 x(:,:,3,1,1) = 1 1 1 1 1 1 x(:,:,4,1,1) = 1 1 1 1 1 1 x(:,:,1,2,1) = 1 1 1 1 1 1 x(:,:,2,2,1) = 1 1 1 1 1 1 x(:,:,3,2,1) = 1 1 1 1 1 1 x(:,:,4,2,1) = 1 1 1 1 1 1 x(:,:,1,3,1) = 1 1 1 1 1 1 x(:,:,2,3,1) = 1 1 1 1 1 1 x(:,:,3,3,1) = 1 1 1 1 1 1 x(:,:,4,3,1) = 1 1 1 1 1 1 x(:,:,1,4,1) = 1 1 1 1 1 1 x(:,:,2,4,1) = 1 1 1 1 1 1 x(:,:,3,4,1) = 1 1 1 1 1 1 x(:,:,4,4,1) = 1 1 1 1 1 1 x(:,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4,7) = 1 1 1 1 1 1 x(:,:,4,4,7) = 1 1 1 1 1 1 x(:,:,1,5,7) = 1 1 1 1 1 1 x(:,:,2,5,7) = 1 1 1 1 1 1 x(:,:,3,5,7) = 1 1 1 1 1 1 x(:,:,4,5,7) = 1 1 1 1 1 1 x(:,:,1,1,8) = 1 1 1 1 1 1 x(:,:,2,1,8) = 1 1 1 1 1 1 x(:,:,3,1,8) = 1 1 1 1 1 1 x(:,:,4,1,8) = 1 1 1 1 1 1 x(:,:,1,2,8) = 1 1 1 1 1 1 x(:,:,2,2,8) = 1 1 1 1 1 1 x(:,:,3,2,8) = 1 1 1 1 1 1 x(:,:,4,2,8) = 1 1 1 1 1 1 x(:,:,1,3,8) = 1 1 1 1 1 1 x(:,:,2,3,8) = 1 1 1 1 1 1 x(:,:,3,3,8) = 1 1 1 1 1 1 x(:,:,4,3,8) = 1 1 1 1 1 1 x(:,:,1,4,8) = 1 1 1 1 1 1 x(:,:,2,4,8) = 1 1 1 1 1 1 x(:,:,3,4,8) = 1 1 1 1 1 1 x(:,:,4,4,8) = 1 1 1 1 1 1 x(:,:,1,5,8) = 1 1 1 1 1 1 x(:,:,2,5,8) = 1 1 1 1 1 1 x(:,:,3,5,8) = 1 1 1 1 1 1 x(:,:,4,5,8) = 1 1 1 1 1 1
y = x(2, 1, 3, 3, 4) % one element of the 5-d array
y = 1
댓글 수: 3이전 댓글 1개 표시이전 댓글 1개 숨기기
Stephen23 2024년 3월 21일
"i think my confusion is more related to not being familar with anything higher tha 2d arrays"
Mathematics is not limited to working in two dimensions, why would MATLAB be?
dareen 2024년 3월 21일
makes sense this language is much more useful than i imagined

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

카테고리

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