fill ids numbers in the matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
EK
el 29 de Abr. de 2023
Comentada: Star Strider
el 29 de Abr. de 2023
Hi,
I am trying to refill excell matrix with trial ids numbers and would like to ask if there are easy way to do it in matlab
I have matrices of 4 columns that log stimuli representation in time (logfile, attached below ). The rows are time and the columns are events. The first column logs stimuli id in time. (No stimulus =0, stimulus : 1 2 3 4 5 or 6) The second column logs the trial stages(1=pre stimulus, 2=stimulus, 3=poststimulus interval); column 4 logs Id of repetition for 6 stimuli.
I need to write in column3 Ids numbers of each trial (pre + stimulus + post) through the length of each trial as in example-logfile (column 3). Files are attached below. For example, first trial in the logfile (column2) is 158 rows (pre + stim +post interval). I need to fill correspondent 158 rows in column 3 with 1 which is ID of the first trial. Next trial with 2 and so on as in an example-logfile (column 3). Could anyone help with this?
0 comentarios
Respuesta aceptada
Star Strider
el 29 de Abr. de 2023
I had to plot ‘example-logfile’ to figure out how it works.
Try this —
TLf = readtable('Logfile.xlsx');
TLf.Var3 = cumsum(diff([0; TLf.Var2])<0)+1
TLf(end-9:end,:)
EDIT — (29 Apr 2023 at 15:26)
It is straightforward to count the ends of the trials and then add them to get ‘Var3’.
.
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!