How to label a class in an array in matlab

4 ビュー (過去 30 日間)
syd
syd 2014 年 3 月 15 日
回答済み: Image Analyst 2014 年 3 月 15 日
So I have this 600 x 6 matrix. This is formed by vertically concatenating 10 10x6 matrix.
I want to know if there is a way to label a class to identify each 10x6 matrix within this 600x6 matrix
For eg
BigMatrix is the 600x6 matrix A is a 10x6 matrix, B is another 10x6 matrix
How would I be able to identify A and B within this BigMatrix
Thanks
  2 件のコメント
per isakson
per isakson 2014 年 3 月 15 日
No, that is not possible with a numerical array, e.g. "600 x 6 matrix".
Image Analyst
Image Analyst 2014 年 3 月 15 日
編集済み: Image Analyst 2014 年 3 月 15 日
I think he made a mistake and meant a 100 row by 6 column matrix, not 600 by 6 because 10 times 10 is 100, not 600.

サインインしてコメントする。

回答 (2 件)

Mischa Kim
Mischa Kim 2014 年 3 月 15 日
Syd, you could use a structure array:
BigMatrix.A = zeros(10,6);
BigMatrix.B = zeros(10,6);
...
  2 件のコメント
syd
syd 2014 年 3 月 15 日
編集済み: Walter Roberson 2014 年 3 月 15 日
but what if i have certain values to be assigned
eg can i do
BigMatrix.A=BigMatrix(10,6)
BigMatrix.B=BigMatrix(20,6)
where (10,6) was the values from matrix A, (20,6) was the values from matrix B
Mischa Kim
Mischa Kim 2014 年 3 月 15 日
You can assign any matrix, or any part of a matrix. E.g.,
HugeMatrix = [1 2 3; 4 5 6; ...
7 8 9; 10 11 12];
BigMatrix.A = HugeMatrix(1:2,:); % first two rows, all cols
BigMatrix.B = HugeMatrix(3:4,:); % rows 3 and 4, all cols
HugeMatrix would be your 600-by-6.

サインインしてコメントする。


Image Analyst
Image Analyst 2014 年 3 月 15 日
Just do this:
labeledMatrix = [ones(10,6);
2*ones(10,6);
3*ones(10,6);
4*ones(10,6);
5*ones(10,6);
6*ones(10,6)]
Every element in that matrix is a number (1 through 6) that says what original array was used to make the array, at that location, by vertical stitching.

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by