How do I code for placing an unknown number of Checkboxes?

Discussion in 'MATLAB' started by Conrad Andrew, Aug 13, 2009.

  1. Hi there

    I'd like to have a simple GUI where a number of checkboxes are placed programmatically. This number depends on user input so may vary. Let's say that on day 1, M may contain ['A1','A2'] but on day 2, it may have ['A1','A2','A3']. How do I generate a code that will place a number of checkboxes dependent on the size of M?

    Thanks very much for any help on this matter
     
    Conrad Andrew, Aug 13, 2009
    #1
    1. Advertisements

  2. Conrad Andrew

    Chaos Guest

    matlab/java has no ability to create code like this, use Perl instead.
     
    Chaos, Aug 13, 2009
    #2
    1. Advertisements

  3. Conrad Andrew

    Shaun Guest


    numChk = inputdlg('Number of Check Boxes');
    numChk = str2double(numChk);
    uh = zeros(1,numChk);
    for i = 1:numChk
    uh(i) = uicontrol('Style','check');
    if i > 1
    pos = get(uh(i-1),'Position');
    pos(2) = pos(2)+20;
    set(uh(i),'Position',pos)
    end
    end


    hth
    Shaun
     
    Shaun, Aug 13, 2009
    #3
  4. This is good stuff Shaun. Exactly what I needed. Thanks a lot!
     
    Conrad Andrew, Aug 14, 2009
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.