MATLAB Answers

creating a matrix from a column vector

4 ビュー (過去 30 日間)
sam van Bohemen
sam van Bohemen 2019 年 11 月 20 日
Answered: 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?

  0 件のコメント

サインイン to comment.

採用された回答

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!

サインイン to comment.

More Answers (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. :)

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。

タグ


Translated by