Understanding higher dimension in MATLAB
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
chaaru datta
il 23 Gen 2024
Commentato: Dyuman Joshi
il 24 Gen 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 Commenti
Stephen23
il 24 Gen 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
il 24 Gen 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.
Risposta accettata
John D'Errico
il 23 Gen 2024
Modificato: John D'Errico
il 23 Gen 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?
Vedere anche
Categorie
Scopri di più su Get Started with Curve Fitting Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!