Finding Table Column Mean, Median and Display

조회 수: 3 (최근 30일)
Amritpal Kaur
Amritpal Kaur 2016년 5월 15일
답변: Matt Cohen 2016년 5월 17일
So I have a Matlab table named wow. I want to find the mean, median of the same and display it in my plot. Here is my code till now:
So my table looks like:
Val1 Val2 Val2 Val4
String String float float
String String float float
...
I am line plotting certain specific Val1 and Val2 pairs via.
T1 = wow(strcmp(wow.Val1, 'Some String') & strcmp(wow.Val2, 'Some String'), :) ;
T2 = wow(strcmp(wow.Val1, 'Some String') & strcmp(wow.Val2, 'Some String'), :) ;
...
subplot1(9, 9, 'Gap', [.01 .02], 'XTickL','Margin','YTickL','Margin','FontS',4);
subplot1(1)
plot( T1.Val3, T1.Val4)
subplot1(9, 9, 'Gap', [.01 .02], 'XTickL','Margin','YTickL','Margin','FontS',4);
subplot1(2)
plot( T2.Val3, T2.Val4)
So, I want to show the mean and median of the Val4 column in each of the plots. That is, I just want to draw a line for the mean and median as it would do using the Data Statistics toolbox.
However, when I use the GUI, as soon as I select data2, my lines for data one disappear!
How do I do it? Thanks. P.S. The subplot1 function.

채택된 답변

Matt Cohen
Matt Cohen 2016년 5월 17일
Hi Amritpal,
I understand that you are interested in why the statistics lines disappear from one subplot when you switch to a different data set in the Data Statistics Tool.
Unfortunately, it is currently not possible to display the statistics information across multiple subplots in the same figure. Only the statistics for the currently selected data set can be displayed. Once you switch to a different data set, the previous data set's statistics lines will disappear from its respective subplot.
One workaround would be to use multiple figures instead of subplots. You get a new Data Statistics Tool per figure. However, this is not exactly an ideal workaround for most situations. Another workaround would be to compute the statistics for each data set and manually plot these statistics values as horizontal lines on the appropriate subplots.
I hope this information helps to answer your specific question.
Matt

추가 답변 (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