added abstract network graph plot

This commit is contained in:
2025-10-27 19:52:10 -07:00
parent b2787e1e53
commit f953cd3882
3 changed files with 29 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ function f = firstPlotSetup(f)
grid(f.Children(1).Children(1), "on");
view(f.Children(1).Children(1), 0, 90);
xlabel(f.Children(1).Children(1), "X"); ylabel(f.Children(1).Children(1), "Y");
title("Top-down Perspective");
% Communications graph
nexttile(3, [1, 1]);
@@ -16,8 +17,10 @@ function f = firstPlotSetup(f)
axis(f.Children(1).Children(1), "image");
grid(f.Children(1).Children(1), "off");
view(f.Children(1).Children(1), 0, 0);
title("Network Graph");
% 3D view
title("3D Perspective");
nexttile(4, [2, 2]);
axes(f.Children(1).Children(1));
axis(f.Children(1).Children(1), "image");
@@ -26,6 +29,7 @@ function f = firstPlotSetup(f)
xlabel(f.Children(1).Children(1), "X"); ylabel(f.Children(1).Children(1), "Y"); zlabel(f.Children(1).Children(1), "Z");
% Side-on view
title("Side-on Perspective");
nexttile(6, [2, 1]);
axes(f.Children(1).Children(1));
axis(f.Children(1).Children(1), "image");
@@ -34,6 +38,7 @@ function f = firstPlotSetup(f)
ylabel(f.Children(1).Children(1), "Y"); zlabel(f.Children(1).Children(1), "Z");
% Front-on view
title("Front-on Perspective");
nexttile(10, [1, 2]);
axes(f.Children(1).Children(1));
axis(f.Children(1).Children(1), "image");

22
miSim.m
View File

@@ -59,7 +59,7 @@ classdef miSim
end
end
obj.adjacency = A;
obj.adjacency = A | A';
end
function f = plotNetwork(obj, f)
arguments (Input)
@@ -97,6 +97,26 @@ classdef miSim
copyobj(o, f.Children(1).Children(5));
end
end
function f = plotGraph(obj, f)
arguments (Input)
obj (1, 1) {mustBeA(obj, 'miSim')};
f (1, 1) {mustBeA(f, 'matlab.ui.Figure')} = figure;
end
arguments (Output)
f (1, 1) {mustBeA(f, 'matlab.ui.Figure')};
end
% Form graph from adjacency matrix
G = graph(obj.adjacency, 'omitselfloops');
% Check if this is a tiled layout figure
if strcmp(f.Children(1).Type, 'tiledlayout')
o = plot(f.Children(1).Children(4), G, 'LineStyle', '--', 'EdgeColor', 'g', 'NodeColor', 'k');
else
o = plot(f.CurrentAxes, G, 'LineStyle', '--', 'EdgeColor', 'g', 'NodeColor', 'k');
end
end
end
methods (Access = private)

View File

@@ -258,6 +258,9 @@ classdef test_miSim < matlab.unittest.TestCase
% Plot communication links
f = tc.testClass.plotNetwork(f);
% Plot abstract network graph
f = tc.testClass.plotGraph(f);
end
end
end