what does this mean , how and for what is it used ?
Show older comments
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 Comments
Sudarsanan A K
on 21 Mar 2024
Hi Dareen,
In MATLAB, the function "ones" is used to create arrays filled with the value 1. The syntax ones(d1, d2, d3, ..., dn) creates an n-dimensional array where d1, d2, d3, ..., dn specify the size of each dimension.
For your specific case:
x = ones(2,3,4,5,8) creates a 5-dimensional array where:
- The first dimension has a size of 2.
- The second dimension has a size of 3.
- The third dimension has a size of 4.
- The fourth dimension has a size of 5.
- The fifth dimension has a size of 8.
This results in an array with a total of
elements, all of which are 1. Such high-dimensional arrays are useful in various advanced applications like data science, machine learning, signal processing, and scientific computing, where they can represent complex data sets or simulations with multiple variables or dimensions.
Manipulating and understanding these high-dimensional arrays require familiarity with MATLAB's array indexing and manipulation capabilities, enabling you to extract, analyze, and visualize the data contained within these structures effectively. Refer the documentation for further understanding:
Hope this helps.
"this i am not sure what it excatly does..."
The documentation already tells you exactly what it does: it creates an array with size 2x3x4x5x8.
".. and what for..."
It is for creating an array with size 2x3x4x5x8. Or any other size:
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.
Accepted Answer
More Answers (0)
Categories
Find more on Resizing and Reshaping Matrices 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!