Understanding higher dimension in MATLAB
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
chaaru datta
el 23 de En. de 2024
Comentada: Dyuman Joshi
el 24 de En. de 2024
Hello all, I am trying to understand about higher dimensions in MATLAB, but not getting it clearly.
For example: a = rand(2,2); ----(1)
I understood that above command in MATLAB will produce random variable "a" having 2 rows and 2 columns.
But I am not getting what will be the output of say b = rand(2,2,3) or b = rand(2,2,3,4) indicates.
Thus my main query is that I am not understanding properly about higher dimension in MATLAB.
Any help in this regard will be highly appreciated.
3 comentarios
Stephen23
el 24 de En. de 2024
A whimsical proposal for some names of dimensions (hopefully with minimal overlap with technical terms):
- row (TMW & maths)
- column (TMW & maths)
- page (TMW)
- book
- shelf
- section
- library
- corpus
See also:
Dyuman Joshi
el 24 de En. de 2024
I was going to propose floor between section and library, but unfortunately that overlaps with floor.
And storey/level does not have the same fit to it.
Respuesta aceptada
John D'Errico
el 23 de En. de 2024
Editada: John D'Errico
el 23 de En. de 2024
Visualize a vector. For example, the vector
V = 1:5
So the numbers 1 through 5, stored in sequence in memory. Got it? rand will do something similar.
rand(1,5)
5 numbers, stored in the vector V.
Do you see that a vector is just a set of scalars, stacked together into a one-dimensional list of numbers?
Next, what is a 2 dimensional array?
A2d = rand(2,3)
2 rows, 3 columns. But it is just a set of 6 numbers here, stored with an associated shape. In this case, a rectangular shape. We can think of it as 3 column vectors, each of length 2, as as 2 row vectors, each of length 3, if you prefer.
A2d(:,1) % the first column of A2d
A2d(1,:) % the first row vector stored in A2d
Got it?
Next, visualize a cube. A cube has three dimensions, right? We can think of that cube as squares, packed on top of each other. But each square can be thought of as 2 dimensional arrays, and we already understand 2 dimensional arrays. (Well, I hope we do.)
So if we extend the idea of a 2-dimensional array as just a set of 1-dimensional vectors, stacked next to each other, or on top of each other, then a 3 -dimensional array is no different. I'll do this one using a vector of integers first, so you can predict what numbers will be where.
A3d = reshape(1:12,[2 2 3])
What do we see there? The first "plane" of that array is a 2x2 matrix. We saw it displayed above, but we can extract it like this:
A3d(:,:,1)
Again, think of a higher dimensinal array as just lower dimensional arrays, stacked up.
R = rand(2,3,4)
So a 2x3x4 array.
Finally, we can stack three dimensional arrays, into a 4-dimensional array. We can see tham all listed below.
b = rand(2,2,2,2)
Unfortunately, our minds live in a 3-dimesinal world. They are not constructed to think in higher dimensions than 3. But surely you can follow the abstract idea of stacking lower dimensional things, to create something with one more dimension?
Más respuestas (1)
Ver también
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!