The original implementation had several separate figure windows for histograms, control chart, and tables, each positioned manually using “scrsz”. This led to windows overlapping or tables being misplaced.
By using “uifigure” with a “uigridlayout”, you can arrange axes and tables neatly in one window. Each item (histogram, control chart, table) sits in a grid cell that resizes automatically.
I have created a simple sample solution for your reference:
%% Dummy data
DRGPS_distance_next_point = randn(500,1)*10 + 100; % histogram data
TestControlChart = randn(25,5) + 10; % control chart data
Stat_matrix = rand(9,4); % stat table
D_count_matrix = randi([0 100],1,3); % D table
%% Dashboard Figure
f = uifigure('Name','Full Dashboard','Position',[100 100 1400 900]);
% 3 rows, 2 columns
gl = uigridlayout(f,[3 2]);
gl.RowHeight = {'1.5x','1x','0.8x'}; % relative row heights
gl.ColumnWidth = {'1x','1x'};
%% Row 1: Four Histograms (original Figure 1 content)
ax1 = uiaxes(gl); histogram(ax1,DRGPS_distance_next_point); title(ax1,'Histogram 1');
ax2 = uiaxes(gl); histogram(ax2,DRGPS_distance_next_point); title(ax2,'Histogram 2');
ax3 = uiaxes(gl); histogram(ax3,DRGPS_distance_next_point); title(ax3,'Histogram 3');
ax4 = uiaxes(gl); histogram(ax4,DRGPS_distance_next_point); title(ax4,'Histogram 4');
ax1.Layout.Row = 1; ax1.Layout.Column = 1;
ax2.Layout.Row = 1; ax2.Layout.Column = 2;
ax3.Layout.Row = 2; ax3.Layout.Column = 1;
ax4.Layout.Row = 2; ax4.Layout.Column = 2;
%% Row 2: Control Chart (spans both columns)
ax5 = uiaxes(gl);
ax5.Layout.Row = 2; ax5.Layout.Column = [1 2];
controlchart(TestControlChart,'chart',{'xbar','r'});
title(ax5,'Control Chart');
%% Row 3: Stat Table (left) and D Table (right)
colnames = {'Value','St. Dev.','Variance','P-value'};
rownames = {'Avg. Total Distance','Avg. Distance > Error Margin',...
'Avg. Distance < Error Margin','Avg. Total # Satellites',...
'Avg. # Satellites > Error Margin','Avg. # Satellites < Error margin',...
'Avg. Total Hdop','Avg. Hdop > Error Margin','Avg. Hdop < Error Margin'};
t1 = uitable(gl,'Data',Stat_matrix,...
'ColumnName',colnames,'RowName',rownames);
t1.Layout.Row = 3; t1.Layout.Column = 1;
colnames2 = {'Total','Distance > Error Margin','Distance < Error Margin'};
rownames2 = {'File contains:'};
t2 = uitable(gl,'Data',D_count_matrix,...
'ColumnName',colnames2,'RowName',rownames2);
t2.Layout.Row = 3; t2.Layout.Column = 2;
The Major changes from the original implementation are:
- Replaced figure windows with one “uifigure”.
- Used “uigridlayout” to automatically arrange plots and tables in a grid instead of manually using “scrsz” and pixel positions.
- Replaced deprecated hist with histogram.
- For tables, used “uitable” inside the grid, so they always resize automatically.
- Control chart is embedded in the dashboard instead of opening in its own floating window.
Also attaching the documentation links of the functions used for reference:
- uifigure : https://www.mathworks.com/help/matlab/ref/uifigure.html
- uigridlayout : https://www.mathworks.com/help/matlab/ref/uigridlayout.html
- uiaxes : https://www.mathworks.com/help/matlab/ref/uiaxes.html
- uitable : https://www.mathworks.com/help/matlab/gui-development.html
- controlchart : https://www.mathworks.com/help/stats/controlchart.html