How to plot two matrices of different sizes in the same figure?

2 views (last 30 days)
Good morning to everybody. I have a file containing some information about the connectivity scheme of a neural network; each entry is something like to (pre,post,weight), where pre refers to the index of the pre-synaptic neuron, post refers to the index of the post-synaptic neuron and weight is the value of the synaptic weight assigned to that specific link. Pre- and postsynaptic populations are separate and I would like to plot the former as a column vector and the latter as a matrix (more specifically: I have just three neurons belonging to the pre-synaptic population, while the post-synaptic one comprises 64 neurons arranged as an 8x8 matrix), both by using imagesc, in order to obtain something like this:
In particular, each pre-synaptic neuron could be connected to a post-synaptic neuron with a synapse whose weight is greater than 0 (red line), otherwise the line should be colored differently (for example, in blue) or, at least, could be completely removed.
How can I solve the problem?

Answers (1)

Joseph Cheng
Joseph Cheng on 30 Mar 2017
Edited: Joseph Cheng on 30 Mar 2017
I would go with something like this
%%gen 8x8 post grid
figure(1),clf, surf([1:8],[1:8],zeros(8,8)),view([0 90]), hold on
%%gen 3x1 pre grid
surf([-2:-1],[3:6],-ones(4,2)),view([0 90]), hold on
%%gen dummy connections
%half into boxes are 0.5
prepoints = [repmat(-1.5,10,1) 3.5+randi(2,10,1)];
postpoints = [1.5+randi(6,10,1) 1.5+randi(6,10,1)];
%for the blue
for ind = 1:5
quiver(prepoints(ind,1),prepoints(ind,2),...
[postpoints(ind,1)-prepoints(ind,1)],[postpoints(ind,2)-prepoints(ind,2)],'b')
end
%for the orange
for ind = 6:10
quiver(prepoints(ind,1),prepoints(ind,2),...
[postpoints(ind,1)-prepoints(ind,1)],[postpoints(ind,2)-prepoints(ind,2)],'r')
end
don't have the time to try to remember why i cannot do all the quiver points all together. Looks like it scales them by how many quivers are being plotted.
but the above is to generate the grids and then link the two based off of what you know goes where. all that is left is to add text and get rid of the axes/grids.
oh and pardon my randi statement. randi doesn't include 0 but they are dummy points anyways

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!