Reducing matrix dimension to a lower dimension

174 ビュー (過去 30 日間)
MiauMiau
MiauMiau 2015 年 12 月 22 日
コメント済み: MiauMiau 2015 年 12 月 22 日
Hi all,
I have a 1 x 400 x 16 matrix (400 measurements, 16 times). I would like to end up simply with a 400 x 16 matrix. Though when I use
reshape(X, [400,16])
it seems that the 400 rows do not correspond to the 400 measurements of one iteration, but that the data is all mixed up. How can I get the dimension I want?
Thanks
  2 件のコメント
Renato Agurto
Renato Agurto 2015 年 12 月 22 日
Your commad semms to be right. Maybe is the way you are looking at the 1x400x16 matrix.
display(X)
Matlab will show 16 arrays horizontally, which may make you think that the matrix is transposed.
what is the result of size(X)? it is really [1 400 16] ?
MiauMiau
MiauMiau 2015 年 12 月 22 日
Hi
Yes, indeed:
>> size(X)
ans =
1 400 16
So for reshape(X,[16,400]) the first row of the columns 1 to 9 is:
-21.0249 -22.2957 -18.9817 -18.0000 -14.7391 -15.5531 -17.2633 -16.4054 -14.0155
(so basically the 9 first measurements of the first measurement (of 16))
But, looking at X, the first 9 column of val(:,:,1) (which is the data from the first measurement from the 16 measurements, so it is up to val(:,:,16) ) are:
-21.0249 -22.5019 -24.1185 -25.7687 -27.3287 -28.6710 -29.6799 -30.2676 -30.3871
..not quite the same.

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

採用された回答

Ingrid
Ingrid 2015 年 12 月 22 日
it looks like it is the squeeze command that you are looking for? Have you tried this:
squeeze(X);

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by