MATLAB Using or Creating block matrices in Matlab

AI Thread Summary
To extract a specific portion of a larger matrix in MATLAB, the command used is matrix indexing. In the example provided, a 12x3 matrix is created, and to obtain a 4x3 subset, the command matrix(1:4,1:3) is utilized. This effectively retrieves the first four rows and all three columns of the matrix. An alternative command, matrix(1:4,:), can also be used to achieve the same result, highlighting the flexibility in MATLAB's indexing capabilities. This approach allows for efficient data management and plotting from larger datasets.
heisenberg90
Messages
1
Reaction score
0
I am trying to put a lot of data into a matrix to call upon later in plotting. From a masterfile, I need to call on the (:,1) values on x and y, and the (:,2) values in x and y. It is easy to construct a 12x3 matrix to contain all of this information, however when I am plotting I want to call only a 4x3 portion of this 12x3 matrix. Which command could I use to limit this call to just that portion of my larger matrix? Thank you in advance!
 
Physics news on Phys.org
You can use a code like this, I will define a matrix of ones for clarity.

Code:
%create matrix
matrix = ones(12,3);

%define 4x3 portion
four_by_three = matrix(1:4,1:3); [I]%note matrix(1:4,:) also works here[/I]
display(four_by_three);
 

Similar threads

Replies
2
Views
3K
Replies
4
Views
2K
Replies
2
Views
2K
Replies
1
Views
3K
Replies
1
Views
4K
Replies
1
Views
5K
Back
Top