added abstract network graph plot
This commit is contained in:
@@ -9,6 +9,7 @@ function f = firstPlotSetup(f)
|
|||||||
grid(f.Children(1).Children(1), "on");
|
grid(f.Children(1).Children(1), "on");
|
||||||
view(f.Children(1).Children(1), 0, 90);
|
view(f.Children(1).Children(1), 0, 90);
|
||||||
xlabel(f.Children(1).Children(1), "X"); ylabel(f.Children(1).Children(1), "Y");
|
xlabel(f.Children(1).Children(1), "X"); ylabel(f.Children(1).Children(1), "Y");
|
||||||
|
title("Top-down Perspective");
|
||||||
|
|
||||||
% Communications graph
|
% Communications graph
|
||||||
nexttile(3, [1, 1]);
|
nexttile(3, [1, 1]);
|
||||||
@@ -16,8 +17,10 @@ function f = firstPlotSetup(f)
|
|||||||
axis(f.Children(1).Children(1), "image");
|
axis(f.Children(1).Children(1), "image");
|
||||||
grid(f.Children(1).Children(1), "off");
|
grid(f.Children(1).Children(1), "off");
|
||||||
view(f.Children(1).Children(1), 0, 0);
|
view(f.Children(1).Children(1), 0, 0);
|
||||||
|
title("Network Graph");
|
||||||
|
|
||||||
% 3D view
|
% 3D view
|
||||||
|
title("3D Perspective");
|
||||||
nexttile(4, [2, 2]);
|
nexttile(4, [2, 2]);
|
||||||
axes(f.Children(1).Children(1));
|
axes(f.Children(1).Children(1));
|
||||||
axis(f.Children(1).Children(1), "image");
|
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");
|
xlabel(f.Children(1).Children(1), "X"); ylabel(f.Children(1).Children(1), "Y"); zlabel(f.Children(1).Children(1), "Z");
|
||||||
|
|
||||||
% Side-on view
|
% Side-on view
|
||||||
|
title("Side-on Perspective");
|
||||||
nexttile(6, [2, 1]);
|
nexttile(6, [2, 1]);
|
||||||
axes(f.Children(1).Children(1));
|
axes(f.Children(1).Children(1));
|
||||||
axis(f.Children(1).Children(1), "image");
|
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");
|
ylabel(f.Children(1).Children(1), "Y"); zlabel(f.Children(1).Children(1), "Z");
|
||||||
|
|
||||||
% Front-on view
|
% Front-on view
|
||||||
|
title("Front-on Perspective");
|
||||||
nexttile(10, [1, 2]);
|
nexttile(10, [1, 2]);
|
||||||
axes(f.Children(1).Children(1));
|
axes(f.Children(1).Children(1));
|
||||||
axis(f.Children(1).Children(1), "image");
|
axis(f.Children(1).Children(1), "image");
|
||||||
|
|||||||
22
miSim.m
22
miSim.m
@@ -59,7 +59,7 @@ classdef miSim
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
obj.adjacency = A;
|
obj.adjacency = A | A';
|
||||||
end
|
end
|
||||||
function f = plotNetwork(obj, f)
|
function f = plotNetwork(obj, f)
|
||||||
arguments (Input)
|
arguments (Input)
|
||||||
@@ -97,6 +97,26 @@ classdef miSim
|
|||||||
copyobj(o, f.Children(1).Children(5));
|
copyobj(o, f.Children(1).Children(5));
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
methods (Access = private)
|
methods (Access = private)
|
||||||
|
|||||||
@@ -258,6 +258,9 @@ classdef test_miSim < matlab.unittest.TestCase
|
|||||||
|
|
||||||
% Plot communication links
|
% Plot communication links
|
||||||
f = tc.testClass.plotNetwork(f);
|
f = tc.testClass.plotNetwork(f);
|
||||||
|
|
||||||
|
% Plot abstract network graph
|
||||||
|
f = tc.testClass.plotGraph(f);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user