Hi
I have a continuesous data with dimensions say yplot = 30 * 200 and I want to plot boxplot with the interval of 10 so that I have 20 plots instead of 200 for better visualization. How to to do it?
On x axis it is n = 1 * 200 - dimensions
figure, boxplot(yplot)

 채택된 답변

Austin M. Weber
Austin M. Weber 2024년 1월 29일

0 개 추천

Are you asking for something like this?
% Fake data
xdata = 1:200;
ydata = randn(30,200);
% Extract every tenth column
idx = 1 : 10 : length(xdata);
xdata_every_10th = xdata(idx);
ydata_every_10th = ydata(:,idx);
% Plot
figure
boxplot(ydata_every_10th)
xticklabels(xdata_every_10th)

댓글 수: 4

Ahmed
Ahmed 2024년 1월 29일
Thanks, one more - a small issue if you can help me, what if I want to plot first 10 data points (wrt x axis) with the interval of 2 and rest of 190 data points with the interval of 10. Then how I can modify this code. Can you help me here plz?
Yes, that is definitely possible:
% Fake data
xdata = 1:200;
ydata = randn(30,200);
% Index for the first ten data points with an interval of 2:
idx_2 = 1 : 2 : 10;
% Index for the remaining data points with an interval of 10:
idx_10 = 19 : 10 : length(xdata);
% Combine indexes
idx_combined = [idx_2 idx_10];
% Extract data at the desired index positions
xdata_intervals = xdata(idx_combined);
ydata_intervals = ydata(:,idx_combined);
% Plot
figure
boxplot(ydata_intervals)
xticklabels(xdata_intervals)
By the way, in addition to boxplot, MATLAB also has a function called boxchart, which I think looks a little better:
figure
boxchart(ydata_intervals)
xticklabels(xdata_intervals)
Ahmed
Ahmed 2024년 1월 31일
Thank you very much. I do not know why boxchart is not working in my MATLAB (2018 version).
Austin M. Weber
Austin M. Weber 2024년 1월 31일
편집: Austin M. Weber 2024년 1월 31일
@Nisar Ahmed, my apologies. The boxchart function was introduced in version R2020.
But, if you want, you have access to most recent version of MATLAB when you use MATLAB Online . No need to download a new Desktop version.

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

추가 답변 (0개)

질문:

2024년 1월 29일

편집:

2024년 1월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by