Storing data in columns not in rows

3 ビュー (過去 30 日間)
Oliver Steiner
Oliver Steiner 2022 年 11 月 3 日
コメント済み: Mathieu NOE 2023 年 2 月 1 日
Hey! I creating this loop to store the data in a matrix. However, the individual values of the participants in one colum. I want each of the values stored in each colum seperately but I dont know how to do it... Thanks
% Define initials of my subjects
subs = { 'P01' 'P02' 'P04' 'P06' 'P07' 'P09' 'P10' 'P11' 'P13' 'P14' 'P17' 'P18' 'P19' 'P20' 'P21' 'P22' 'P24' 'P25' 'P26'};
% Get the lenght of the array with my subjects
length_subs = size(subs,2);
% Define columns
rewCol = 5;
timeCol = 46;
load(sprintf('expResEye_P01_AllB.mat', char(subs(1, sub))))
sub_data = configEyeAll{1,6}.resMatCor
% Create empty arrays
all_subs_data = [];
% Here, we load the data of each subjects in "subs" array
for sub = 1:length_subs
load(sprintf('expResEye_%s_AllB.mat', char(subs(1, sub))))
sub_data = configEyeAll{1,6}.resMatCor;
vector_cor = sub_data(:,46)
indiv_data = [vector_cor]
all_subs_data = [indiv_data;all_subs_data];
end

採用された回答

Mathieu NOE
Mathieu NOE 2022 年 11 月 3 日
hello
why not use a structure or a table ?
it's much appropriate when dealing with variable size data sets
% Define initials of my subjects
subs = { 'P01' 'P02' 'P04' 'P06' 'P07' 'P09' 'P10' 'P11' 'P13' 'P14' 'P17' 'P18' 'P19' 'P20' 'P21' 'P22' 'P24' 'P25' 'P26'};
% Get the lenght of the array with my subjects
length_subs = size(subs,2);
% structure
for ci = 1:length_subs
S(ci).name = subs{ci};
S(ci).data = rand(5+3*ci,1);
end
  5 件のコメント
Oliver Steiner
Oliver Steiner 2023 年 2 月 1 日
I am very sorry for the late reply. But it worked like this. So thx!
Mathieu NOE
Mathieu NOE 2023 年 2 月 1 日
as always , my pleasure !

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNonlinear Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by