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

2 次查看(过去 30 天)
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 个评论
Stephen23
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
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

请先登录,再进行评论。

采纳的回答

Chunru
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(:,:,1,5,1) = 1 1 1 1 1 1 x(:,:,2,5,1) = 1 1 1 1 1 1 x(:,:,3,5,1) = 1 1 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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 个评论
Stephen23
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
dareen 2024-3-21
makes sense this language is much more useful than i imagined

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by