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

2 Ansichten (letzte 30 Tage)
dareen
dareen am 21 Mär. 2024
Bearbeitet: dareen am 21 Mär. 2024
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 Kommentare
Stephen23
Stephen23 am 21 Mär. 2024
Bearbeitet: Stephen23 am 21 Mär. 2024
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 am 21 Mär. 2024
Bearbeitet: dareen am 21 Mär. 2024
@Stephen23 thanks the example is really useful cleared this a lot, hopefully will impelement this in future codes

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Chunru
Chunru am 21 Mär. 2024
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(:,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4,7) = 1 1 1 1 1 1 x(:,:,3,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 Kommentare
Stephen23
Stephen23 am 21 Mär. 2024
"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 am 21 Mär. 2024
makes sense this language is much more useful than i imagined

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by