creating a matrix from a column vector

70 ビュー (過去 30 日間)
sam van Bohemen
sam van Bohemen 2019 年 11 月 20 日
回答済み: Darshan Sen 2019 年 11 月 20 日
I want to analyse some EEG data by breaking the total samples into 1 second segments. The total number of samples for each channel is 136704. The sampling rate of the EEG device is 128Hz, therefore I want to create segments of data with 128 samples. This will result in 1068 segments for each channel.
The total samples for one channel = x
How can I create a 128 x 1068 matrix from x? So each coulmn represents 1 second (128 samples) of the total samples?

採用された回答

Erivelton Gualter
Erivelton Gualter 2019 年 11 月 20 日
Lets say you have your signal (EEG_signal):
EEG_signal = rand(1,136704); % Sample SIgnal
You can reshape this on matrix format:
EEG_signal_matrix = reshape(x, 128, 1068);
  1 件のコメント
sam van Bohemen
sam van Bohemen 2019 年 11 月 20 日
Thanks for your help!

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

その他の回答 (1 件)

Darshan Sen
Darshan Sen 2019 年 11 月 20 日
Hello Sam. I guess we can solve your problem using the reshape function that MATLAB provides.
I'll walk you through a very simple example where, I am considering x to be a -dimensional column vector and I'll reshape it into a matrix with 3 rows and 5 columns and store it in y.
>> x = rand(15, 1)
x =
0.3044
0.6476
0.1739
0.0302
0.6322
0.3122
0.6367
0.6452
0.4710
0.2619
0.1978
0.6550
0.0990
0.5368
0.9916
>> y = reshape(x, 3, 5)
y =
0.3044 0.0302 0.6367 0.2619 0.0990
0.6476 0.6322 0.6452 0.1978 0.5368
0.1739 0.3122 0.4710 0.6550 0.9916
If this is the kind of functionality you want, you may change the dimensions and fill in your own data.
If you want to know more about the reshape function, you may type help reshape into the MATLAB console and I'm sure it'll guide you well.
Hope this helps. :)

カテゴリ

Help Center および File ExchangeBiomedical Signal Processing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by