I have a Table with 2 different set of experiments. each experiments have 2 subexperiments. each subexperiment have 5 sets of data. How to plot a graph of each subexperiment results? I need a plot of all subexperiments.

 Réponse acceptée

Peter Perkins
Peter Perkins le 18 Mai 2017
You don't need table2array.
Your example data don't seem to match either description, so I'm just guess what they look like. Also you don't say what kind of plot.
>> type = [1;1;1;1;1;2;2;2;2;2;3;3;3;3;3];
>> subexperiment = [1;2;3;4;5;1;2;3;4;5;1;2;3;4;5];
>> result = randn(15,1);
>> t = table(type,subexperiment,result)
t =
15×3 table
type subexperiment result
____ _____________ __________________
1 1 -0.204966058299775
1 2 -0.124144348216312
1 3 1.48969760778546
1 4 1.40903448980048
1 5 1.41719241342961
2 1 0.67149713360808
2 2 -1.20748692268504
2 3 0.717238651328838
2 4 1.63023528916473
2 5 0.488893770311789
3 1 1.03469300991786
3 2 0.726885133383238
3 3 -0.303440924786016
3 4 0.293871467096658
3 5 -0.787282803758638
>> i1 = (t.type == 1);
>> plot(t.subexperiment(i1),t.result(i1))
That plots all the type 1 results. Put that in a loop, perhaps using subplot. It's also pretty simple to do something like
rowfun(@plot,t,'GroupingVariable','type','NumOutputs',0)
but actually you'd need to write a two-line function that made a new figure window or paused or something, otherwise you'll only see the last plot.

4 commentaires

Pratheek Manangi
Pratheek Manangi le 18 Mai 2017
Modifié(e) : Pratheek Manangi le 19 Mai 2017
Thanks for ur reply. But what if the elements are cell type?
Undefined operator '==' for input arguments of type 'cell'.
Pratheek Manangi
Pratheek Manangi le 22 Mai 2017
Modifié(e) : Pratheek Manangi le 22 Mai 2017
@Guillaume or @Peter perkins could u please reply
Peter Perkins
Peter Perkins le 23 Mai 2017
Create a short example of actual code that you are using, using a small sample of exactly the kind of data you have, and show exactly what you are trying to do, and where you are running into problems.
Pratheek Manangi
Pratheek Manangi le 24 Mai 2017
I figured it out. Thanks

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by