I have multiple datasets (txt files) from experiments, containing rows with trials and columns with data from these trials. The data is sampled at some frequency so there are many rows per trial.
trial data1 data2 ....
1 # #
1 # #
2 # #
2 # #
3 # #
.
.
How can I easily split each dataset in single trials and assign them a new name?
Currently I have the following:
filename = 'Participant9.txt';
delimiterIn = ' ';
headerlinesIn = 1;
Measurements = importdata(filename,delimiterIn,headerlinesIn);
trial1 = Measurements.data(Measurements.data(:,1)==1,:);
etc....
This is a lot of manual work to do for 255 trials, with 28 columns per trial to analyze. So I'm looking for a way to automate the division into trials, with their own names.

 Respuesta aceptada

Jan
Jan el 2 de Oct. de 2018
Editada: Jan el 2 de Oct. de 2018
Do not hide indices in the names of variables line in "trial1". See Why and how to avoid EVAL .
trial = cell(1, 255);
for k = 1:255
trial{k} = Measurements.data(Measurements.data(:,1)==k, :);
end
Now trial{1} contains the first data set.

Más respuestas (0)

Categorías

Más información sobre File Operations en Centro de ayuda y File Exchange.

Preguntada:

el 2 de Oct. de 2018

Comentada:

el 2 de Oct. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by