필터 지우기
필터 지우기

How to group data in two column matrix

조회 수: 3 (최근 30일)
leonidas86
leonidas86 2018년 5월 16일
댓글: leonidas86 2018년 5월 17일
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!

채택된 답변

Matt J
Matt J 2018년 5월 16일
Use splitapply() for the groupwise mean and bar() to generate the bar plot.
  댓글 수: 14
leonidas86
leonidas86 2018년 5월 17일
편집: leonidas86 2018년 5월 17일
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 2018년 5월 17일
I made it:
xTick=round(groupPosMeans);
set(gca, 'XTick', xTick);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by