Table - conditional maths and plots from variables
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Thiago de Aquino Costa Sousa
le 18 Sep 2022
Commenté : Thiago de Aquino Costa Sousa
le 21 Sep 2022
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 commentaires
Chunru
le 19 Sep 2022
Try to upload a mat file:
data = yourdata(1:200, :); % 1:200 or other number to demonstrate your case
Réponse acceptée
Paul
le 19 Sep 2022
Check out splitapply
7 commentaires
Paul
le 20 Sep 2022
Modifié(e) : Paul
le 20 Sep 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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!