How to group data in two column matrix

2 visualizzazioni (ultimi 30 giorni)
leonidas86
leonidas86 il 16 Mag 2018
Commentato: leonidas86 il 17 Mag 2018
Hello, I have a set of data that I would like to analyse. The data is split into two columns in a matrix. Here is a cutout:
16,7115184526445 1,99856679248824
16,7765766713840 1,90380826928436
16,8203225632002 1,90759997561475
16,9296872927408 1,93705728785794
17,0247496340434 1,95221030451463
17,0840560047515 1,97156344341112
17,1728721040053 2,02042344983047
17,2760126971073 2,04365662563518
17,3427845325050 1,99056685824960
17,3555146973138 1,96334283757260
17,3614789932988 1,92935199439745
17,3759202152813 1,94379321637992
17,4269340102000 1,91489959400124
17,4440061891234 9,29514481185319
17,5122505102985 1,76049098118472
17,5544684974967 1,96252475665197
17,5760555781573 1,94415765182676
17,6300232798089 1,95817212166681
17,6986099837662 1,66717115625156
17,7054927064216 1,99368640911937
17,7158167904047 1,92410307580507
17,7416270003624 1,94991328576274
17,8656023527728 1,99398026720148
Now I want to group the left data into 10 classes like 10,20,30,40 etc... and calculate the mean values of the right data for each group. In a next step I want to plot the data with a bar for each group. I have sort the matrix according to the left column with sortrows. How can i go on?
Thanks for your help!

Risposta accettata

Matt J
Matt J il 16 Mag 2018
Use splitapply() for the groupwise mean and bar() to generate the bar plot.
  14 Commenti
leonidas86
leonidas86 il 17 Mag 2018
Modificato: leonidas86 il 17 Mag 2018
I have one last question about plotting the histogram.
groupPosMeans = accumarray(groupID,pPos,[],@mean);
Above I calculated my x axis values. Then plotting with:
bar(groupPosMeans,groupDiffMeans);
How can I set the right x axis scale according to groupPosMeans?
leonidas86
leonidas86 il 17 Mag 2018
I made it:
xTick=round(groupPosMeans);
set(gca, 'XTick', xTick);

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by