Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab GUI: putting several edit text inputs in one matrix

  1. Mar 29, 2010 #1
    Matlab GUI: putting several "edit text" inputs in one matrix

    I'm making a Matlab GUI that will ultimately send data to a robot. I have about 60 numbers being 6 polynomials of 10 terms. My "edit text"-boxes are currently named motG_RN_0 where the R can also be an S or a T and the N can also be a D. The number ranges from 0 to 9.

    I would like my 60 values to be stored in a 6x10 matrix. That would be the easiest way to tranfer them between the different pages of my GUI and to store them.

    I tried writing 6 for-loops (one for each row of the matrix) and make the number in the name change automatically but that didn't work. I tried using the eval-function but that didn't seem to work in combination with <<get(handles.motG_RN_x,'String')>>.
    The most practical would be if I could directly link each box with an entry in the matrix. That way I could also easily load a matrix and display it in the boxes. Tagging the boxes as e.g. A(1) is not accepted and I'm out of ideas on how it could possibly work.

    Does anyone know how to solve this problem?
    best regards
  2. jcsd
  3. Mar 29, 2010 #2


    Staff: Mentor

    Re: Matlab GUI: putting several "edit text" inputs in one matrix

    I don't quite understand the roles of the edit text boxes in all this.

    You can fill a 6 x 10 matrix with nested do loops like this:
    Code (Text):

    do i=1:6
      do j=1:10
        % input the jth number in the ith polynomial
    You might be able to display the appropriate edit box inside the outer loop but before the inner loop by mapping the i value to the appropriate motG_XX_n text box, but it seems like an awful lot of work for the user to have to wade through 60 separate text boxes.

    With so much input, you might instead consider reading input from an input file, and filling the array from that file.
  4. Mar 31, 2010 #3
    Re: Matlab GUI: putting several "edit text" inputs in one matrix

    I could indeed work with nested loops or even with an edit box that allows matrix input, but that would kind of ruin the purpose of a GUI.
    I've been asked to make an interface for the robot as a part of my graduation project. I kind of want it to look good.
    I now have something that looks like <<"edit text"+"z^-9"+"edit text"+"z^-8"+...>>
    where the "z^-x" is static text.
    By using the tab-key you can easily scroll through the different boxes so I don't think that's really a problem. It certainly improves the overview which will probably result in fewer input faults.
    I will make it possible to load a matrix from another file. That will make it possible for other people to write addition to my program. But while just reading input from an input file would be a real practical solution, it wouldn't be a good looking one.
  5. Apr 1, 2010 #4


    Staff: Mentor

    Re: Matlab GUI: putting several "edit text" inputs in one matrix

    Just some thoughts ....

    I don't know what information your program needs, but it seems to me that asking a user to input 60 different numbers might tend to be very frustrating. No matter how nice you make the GUI, with that many inputs, getting one wrong and having to navigate through your GUI to redo it, or even having to go through the whole thing again is a lot to ask of the user.

    I would lean heavily toward batch input of this many numbers (via an input text file), or maybe think a little more about what information is actually needed. Could your program calculate some of the values so that not all of them would have to be entered?
  6. Apr 1, 2010 #5
    Re: Matlab GUI: putting several "edit text" inputs in one matrix

    The input consists of 3 fractions, each having a numerator and a denominator of 10 terms. They make up a regulator to control the robots motor.
    10 terms is quite a lot for a regulator. Most of the times the users will only use 3 to 5 of those terms. The rest they can just leave on there default value (=0).
    If I would use nested loops or ask them to input a matrix they would have to input all 60 numbers. By using separate boxes, they can just click on the box they want to change.
    Look at is as kind of an excel-file. There's an overview of all the numbers and you just click on the ones you want to change.
    The actual input is not part of my assignment so I don't know how much of it can be calculated. If ever someone else writes a program to calculate values for mine, I will make it possible to import them as long as they're stored in a matrix of the appropriate size.

    I actually solved my problem yesterday by adressing each box individually and putting that in a function in order to improve readability of my main code. I just wanted to know if it is possible to write it in a shorter way by using loops or any other method.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook