-
Notifications
You must be signed in to change notification settings - Fork 1
/
PlotGHNG.m
45 lines (37 loc) · 2 KB
/
PlotGHNG.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function [Handle]=PlotGHNG(Model,MyAxis)
% Plot a GHNG model in 2D
% E.J. Palomo
% Inputs:
% Model = GHNG model
% MyAxis = Vector of four components to scale the plot
Handle = [];
hold on
PlotGHNGRec(Model,MyAxis,1);
function PlotGHNGRec(Model,MyAxis,Level)
if ~isempty(Model) && (Level <= 4),
Colors = [0.4 0.2 0;1 0 0;1 0.65 0;0 1 1];
MyColor = Colors(Level,:);
% Draw the child maps
for NdxNeuro=1:numel(Model.Child),
PlotGHNGRec(Model.Child{NdxNeuro},MyAxis,Level+1);
end
% Draw the neurons
% plot(Model.Means(1,:),Model.Means(2,:),'or','LineWidth',1,'MarkerFaceColor',MyColor,'MarkerSize',15*(1/Level));
plot(Model.Means(1,:)*MyAxis(2)+MyAxis(1),Model.Means(2,:)*MyAxis(4)+MyAxis(3),'or','LineWidth',1,'MarkerFaceColor',MyColor,'MarkerSize',15*(1/Level));
% plot(Model.Means(1,:)*MyAxis(2),Model.Means(2,:)*MyAxis(4),'or','LineWidth',1,'MarkerFaceColor',MyColor,'MarkerSize',15*(1/Level));
% Draw the vertical connections
NumNeurons = size(Model.Means,2);
for NdxUnit=1:NumNeurons,
if isfinite(Model.Means(1,NdxUnit))
NdxNeighbors = find(Model.Connections(NdxUnit,:));
for NdxMyNeigh=1:numel(NdxNeighbors)
% line([Model.Means(1,NdxUnit) Model.Means(1,NdxNeighbors(NdxMyNeigh))],...
% [Model.Means(2,NdxUnit) Model.Means(2,NdxNeighbors(NdxMyNeigh))],'Color',MyColor);
line([Model.Means(1,NdxUnit)*MyAxis(2)+MyAxis(1) Model.Means(1,NdxNeighbors(NdxMyNeigh))*MyAxis(2)+MyAxis(1)],...
[Model.Means(2,NdxUnit)*MyAxis(4)+MyAxis(3) Model.Means(2,NdxNeighbors(NdxMyNeigh))*MyAxis(4)+MyAxis(3)],'Color',MyColor);
% line([Model.Means(1,NdxUnit)*MyAxis(2) Model.Means(1,NdxNeighbors(NdxMyNeigh))*MyAxis(2)],...
% [Model.Means(2,NdxUnit)*MyAxis(4) Model.Means(2,NdxNeighbors(NdxMyNeigh))*MyAxis(4)],'Color',MyColor);
end
end
end
end