Table - conditional maths and plots from variables

1 visualización (últimos 30 días)
Dear all,
I have a 57254x87 table, on which I need to perform some maths and plots with the tables. I have one column called Subject_Id (total of 8 particpants) and another one called Trial_Id (a total of 6 per particpant), and I need to plot the data from two others variables. For example, I am looking for a code that will take the first subject, then run a loop for each one of the 6 trials, ploting the data of my columns 3 and 4, and then take the second subject, and reproduces the same thing one more time, and so on for the 8 subjects.
I guess I need one loop inside the other, but I am not sure how to do it.
Any help will be very much appreciated.
  3 comentarios
Thiago de Aquino Costa Sousa
Thiago de Aquino Costa Sousa el 19 de Sept. de 2022
@Chunru please considerer the number of the columns, because I was not able to copy the name of th variables. Subject_Id (column 86) Trial_Id (column 87) Xdisplacement (column 3) Ydisplacement (column 4). Thank you for your help.
914371 0.00356000000000000 -0.448190000000000 -3.46237000000000 161.552200000000 -0.0869400000000000 0.360670000000000 88.6375000000000 109.142620000000 514.040590000000 95.0959900000000 0 539.880920000000 83.5962300000000 -103.920560000000 504.995670000000 86.7854700000000 1 1 -3.46237000000000 0.670540000000000 540.376160000000 139.983540000000 0 539.880920000000 83.5962300000000 15.9204300000000 540.506470000000 133.368580000000 21.9610100000000 539.172970000000 108.898650000000 24.9944700000000 529.957210000000 85.0114200000000 10.8748500000000 535.254210000000 2.82422000000000 -17.1000100000000 543.319520000000 132.028410000000 -20.8233700000000 541.126340000000 106.628250000000 -23.7434300000000 528.965700000000 83.6034500000000 -6.90171000000000 534.684630000000 3.54805000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 160.581540000000 0 0 -1.00000000000000e-05 0 0 160.581540000000 0 0 -1.00000000000000e-05 'Empty' 'None' 'HTY01' 'Trial_1_2Mi'
914372 0.00912000000000000 -0.448190000000000 -3.46237000000000 161.552200000000 -0.0869400000000000 0.360670000000000 88.6375000000000 109.142620000000 514.040590000000 95.0959900000000 0 539.880920000000 83.5962300000000 -103.920560000000 504.995670000000 86.7854700000000 1 1 -3.46237000000000 0.670540000000000 540.376160000000 139.983540000000 0 539.880920000000 83.5962300000000 15.9204300000000 540.506470000000 133.368580000000 21.9610100000000 539.172970000000 108.898650000000 24.9944700000000 529.957210000000 85.0114200000000 10.8748500000000 535.254210000000 2.82422000000000 -17.1000100000000 543.319520000000 132.028410000000 -20.8233700000000 541.126340000000 106.628250000000 -23.7434300000000 528.965700000000 83.6034500000000 -6.90171000000000 534.684630000000 3.54805000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 160.581540000000 0 0 -1.00000000000000e-05 0 0 160.581540000000 0 0 -1.00000000000000e-05 'Empty' 'None' 'HTY01' 'Trial_1_2Mi'
914373 0.0146700000000000 -0.424390000000000 -3.43538000000000 161.535980000000 -0.0347900000000000 0.281270000000000 88.6616000000000 109.142620000000 514.040590000000 95.0959900000000 0 539.880920000000 83.5962300000000 -103.920560000000 504.995670000000 86.7854700000000 2 1 -3.43538000000000 0.670540000000000 540.376160000000 139.983540000000 0 539.880920000000 83.5962300000000 15.9204300000000 540.506470000000 133.368580000000 21.9610100000000 539.172970000000 108.898650000000 24.9944700000000 529.957210000000 85.0114200000000 10.8748500000000 535.254210000000 2.82422000000000 -17.1000100000000 543.319520000000 132.028410000000 -20.8233700000000 541.126340000000 106.628250000000 -23.7434300000000 528.965700000000 83.6034500000000 -6.90171000000000 534.684630000000 3.54805000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 160.581540000000 0 0 -1.00000000000000e-05 0 0 160.581540000000 0 0 -1.00000000000000e-05 'Empty' 'None' 'HTY01' 'Trial_1_2Mi'
914374 0.0202300000000000 -0.424390000000000 -3.43538000000000 161.535980000000 -0.0347900000000000 0.281270000000000 88.6616000000000 109.142620000000 514.040590000000 95.0959900000000 0 539.880920000000 83.5962300000000 -103.920560000000 504.995670000000 86.7854700000000 2 1 -3.43538000000000 0.670540000000000 540.376160000000 139.983540000000 0 539.880920000000 83.5962300000000 15.9204300000000 540.506470000000 133.368580000000 21.9610100000000 539.172970000000 108.898650000000 24.9944700000000 529.957210000000 85.0114200000000 10.8748500000000 535.254210000000 2.82422000000000 -17.1000100000000 543.319520000000 132.028410000000 -20.8233700000000 541.126340000000 106.628250000000 -23.7434300000000 528.965700000000 83.6034500000000 -6.90171000000000 534.684630000000 3.54805000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 160.581540000000 0 0 -1.00000000000000e-05 0 0 160.581540000000 0 0 -1.00000000000000e-05 'Empty' 'None' 'HTY01' 'Trial_1_2Mi'
Chunru
Chunru el 19 de Sept. de 2022
Try to upload a mat file:
data = yourdata(1:200, :); % 1:200 or other number to demonstrate your case

Iniciar sesión para comentar.

Respuesta aceptada

Paul
Paul el 19 de Sept. de 2022
Check out splitapply
  7 comentarios
Paul
Paul el 20 de Sept. de 2022
Editada: Paul el 20 de Sept. de 2022
Only one splitapply is needed
Create some data in a table.
rng(100)
T = table;
T.subj = [ones(10,1); 2*ones(10,1)];
T.trial = 3*randi(2,20,1);
T.col3 = (1:20).';
T.col4 = T.subj + T.trial;
Make the plots
G = findgroups(T.subj,T.trial);
splitapply(@(subj,trial,col3,col4) makeplot(subj(1),trial(1),col3,col4),T.subj,T.trial,T.col3,T.col4,G);
function makeplot(subj,trial,col3,col4)
figure
plot(col3,col4,'-o')
title("subj = " + double(subj) + ", trial = " + double(trial));
end
Thiago de Aquino Costa Sousa
Thiago de Aquino Costa Sousa el 21 de Sept. de 2022
Hey @Paul, thank you for replying to me. I will plot my data on your code and check what happens next... sincerely, Thiago

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by