0 Replies - 598 Views - Last Post: 18 April 2012 - 09:50 AM Rate Topic: -----

#1 bhavin5  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 61
  • Joined: 29-November 11

[MatLab] button game. simple

Posted 18 April 2012 - 09:50 AM

hello i am trying to create a button game. where there are n number of buttons. (i have 5). where every time you click on the button it goes.
at the moment it only works for the fist button. can you help me please.

i know its something to do with the creating of the button. in the for loop

clear all, clc, close all

fh = figure;

n = 3;
x = ceil(rand(10)*2);
y = ceil(rand(10)*2);

bgh = uibuttongroup('Parent',fh,'Title',...
    'Button Game','Position',[.1 .2 .8 .6]);


for i = 1:n
    rbh1 = uicontrol(bgh,'Style','Pushbutton','String','Red',...
        'Units','normalized','Position',[rand(1) rand(1) x(1,i) y(1,i)]);

    set(rbh1,'CallBack','set(rbh1,''visible'',''off'')')

end

axt = axes('Parent',bgh,'Units','normalized');

axis([0.5 1 0.5 1])
axis square
axis off


Is This A Good Question/Topic? 0
  • +

Page 1 of 1