Understanding size() Function for 2x2 Matrices

  • Context: MATLAB 
  • Thread starter Thread starter tgt
  • Start date Start date
  • Tags Tags
    Function Matrices
Click For Summary

Discussion Overview

The discussion revolves around the function size() in relation to 2x2 matrices, specifically addressing how dimensions are defined and interpreted in this context. Participants explore the implications of the size function for matrices of different dimensions and the conceptual understanding of matrix dimensions.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • Some participants explain that size(A,n) returns the length along the nth dimension of the matrix A, noting that for a 2x2 matrix, size(A,n) equals 2 for n=1 and n=2, and equals 1 for n>2.
  • One participant questions the definition of dimensions, suggesting that a 2x2 matrix could be considered to have a dimension of 4, and seeks clarification on what is meant by the nth dimension.
  • Another participant clarifies that in this context, the first dimension refers to the number of columns and the second dimension refers to the number of rows, proposing that a 2x2 matrix can be viewed as a single entry in a list of matrices.
  • A later reply challenges the previous clarification, asserting that the first dimension should be the number of rows and the second dimension the number of columns, based on their experience with a 3 by 2 matrix.
  • There is a suggestion that it would be more intuitive if MATLAB returned 0 for the size of higher dimensions of matrices.

Areas of Agreement / Disagreement

Participants express differing views on the definition of dimensions in the context of matrices, with no consensus reached on whether the first dimension should be considered as rows or columns. The discussion remains unresolved regarding the interpretation of dimensions in relation to the size function.

Contextual Notes

Participants are navigating the definitions and implications of matrix dimensions, with some assumptions about how dimensions are counted in MATLAB. There is also an exploration of the behavior of the size function for matrices beyond the second dimension.

tgt
Messages
519
Reaction score
2
What does the function size(A,1) and size(A,2) and size(A,32) mean for a random (in other words, any) 2 by 2 matrix?
 
Physics news on Phys.org
size(A,n) returns the length along the nth dimension of the matrix A.

This means that for a 2x2 matrix (i.e a 2D matrix) for n>2 we have that size(A,n)=1 but for n=1,2 size(A,n)=2 since it is only in the first two dimensions that the matrix has any entries.
 
cpt_carrot said:
size(A,n) returns the length along the nth dimension of the matrix A.

This means that for a 2x2 matrix (i.e a 2D matrix) for n>2 we have that size(A,n)=1 but for n=1,2 size(A,n)=2 since it is only in the first two dimensions that the matrix has any entries.

What is the nth dimension of a matrix A? How is dimension defined?

Isn't it the case that the dimension of a 2x2 matrix is 4?

Or are you referring to that dimension 1 of a matrix is the number of rows. 2nd dimension of a matrix is the column size? But what is the 3rd dimension of a matrix?
 
Last edited:
In this context, the first "dimension" is the number of columns, and the second "dimension" is the number of rows.

A 2x2 matrix can be thought of as a single entry in a 1-element long list of 2x2 matrices, which is why the higher "dimensions" in MATLAB all have length 1.

- Warren
 
chroot said:
In this context, the first "dimension" is the number of columns, and the second "dimension" is the number of rows.

A 2x2 matrix can be thought of as a single entry in a 1-element long list of 2x2 matrices, which is why the higher "dimensions" in MATLAB all have length 1.

- Warren

I think it's the opposite after trying it on a 3 by 2 matrix. First dimension is the number of rows and second dimension is the number of columns.

However, it would make more sense if MATLAB gave 0 as the size of the higher dimensions of matrices.
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K