How to use the uimenu to assing value to variables

조회 수: 6(최근 30일)
Sadegh Salesi Mousaabadi
Sadegh Salesi Mousaabadi 2017년 1월 23일
댓글: Greg Heath 2018년 11월 28일
I am going to develop a neuron network topology in which the topology is layered (like a neural network). Due to plenty number of neurons, we cannot ask the user to assign value to each neuron model and type and the best option is to assume that all the neurons have the same type and model initially and wherever necessary the user to be able to change the each neuron type or model using a right-click option on the figure. The code below is a very simple topology of 8 neurons (2 inputs, 3 neurons in layer 1, 2 neurons in layer 2 and, 1 output neuron)
clc,clear
NoNeuron=8;
NoInNeuron=2;
NoOutNeuron=1;
NoLayers=2;
NoNeuronL1=3;
NoNeuronL2=2;
NoType=NoLayers+1+1;
emp.x=[];
emp.y=[];
emp.type=[];
emp.model=[];
Neuron=repmat(emp,NoNeuron,1);
x=[1;1;2;2;2;3;3;4];
y=[2;4;1;3;5;2;4;3];
hold on
line([1 2],[4 5])
line([1 2],[4 3])
line([1 2],[4 1])
line([1 2],[2 5])
line([1 2],[2 3])
line([1 2],[2 1])
line([2 3],[5 4])
line([2 3],[5 2])
line([2 3],[3 4])
line([2 3],[3 2])
line([2 3],[1 4])
line([2 3],[1 2])
line([3 4],[4 3])
line([3 4],[2 3])
net=plot(x,y,'mo','LineWidth',2,'MarkerSize',15,'MarkerEdgeColor','g','MarkerFaceColor','r');
axis([0,5,0,6])
c = uicontextmenu;
net.UIContextMenu = c;
topmenu = uimenu('Parent',c,'Label','Neuron Model');
topmenu1 = uimenu('Parent',c,'Label','Neuron Type');
m1 = uimenu('Parent',topmenu,'Label','Integrate and fire');
m2 = uimenu('Parent',topmenu,'Label','Leaky integrate and fire ');
m3 = uimenu('Parent',topmenu,'Label','Izhikevich');
t1 = uimenu('Parent',topmenu1,'Label','Type1');
t2 = uimenu('Parent',topmenu1,'Label','Type2');
t3 = uimenu('Parent',topmenu1,'Label','Type3');
set(gca,'YTick',[]);
set(gca,'XTick',[]);
If you run this code the topology would be drawn. The neurons are structured to have x position, y position, type, and model. For this simple example, the value of x and y positions are entered manually. For right-click option, I used uimenu function so if you right-click on each neuron the options for neuron type and model would appear. What I want now is that whenever the user click on each neuron type (model) in the figure, its value is kept in the corresponding neuron type (model) in the main algorithm.
Anyone any suggestion?
I would appreciate your helps and suggestions
thanks
  댓글 수: 1
Greg Heath
Greg Heath 2018년 11월 28일
Input nodes are not neurons
Hope this helps.
Greg

댓글을 달려면 로그인하십시오.

답변(1개)

Chirag Parekh
Chirag Parekh 2017년 1월 27일
편집: Chirag Parekh 2017년 1월 27일
I did not get which value you want to save, but you can use callback functions to do such things.
t1 = uimenu('Parent',topmenu1,'Label','Type1', 'Callback',@myfunc);
%nyfunc.m
function myfunc(src,evt)
disp('In myfunc');
end

태그

Community Treasure Hunt

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

Start Hunting!

Translated by