Matlab GUI: putting several edit text inputs in one matrix

In summary: It is possible to write it in a shorter way by using loops. It is also possible to write it in a shorter way by using an input text box that allows matrix input.
  • #1
robuLAB
5
0
Matlab GUI: putting several "edit text" inputs in one matrix

Hi,
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
 
Physics news on Phys.org
  • #2


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:
do i=1:6
  do j=1:10
    % input the jth number in the ith polynomial
  end
end

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.
 
  • #3


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.
 
  • #4


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?
 
  • #5


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.
 

Related to Matlab GUI: putting several edit text inputs in one matrix

1. How do I create a matrix of edit text inputs in Matlab GUI?

To create a matrix of edit text inputs in Matlab GUI, you can use the "uicontrol" function and specify the style as "edit" and the position of the input in the matrix. You can also use the "set" function to set the tag and callback function for each input.

2. Can I set the size and format of the matrix of edit text inputs?

Yes, you can set the size and format of the matrix of edit text inputs by specifying the number of rows and columns in the "uigridlayout" function. You can also use the "set" function to specify the format of each input, such as the font, color, and alignment.

3. How do I retrieve the values from the matrix of edit text inputs?

To retrieve the values from the matrix of edit text inputs, you can use the "get" function and specify the tag of the input. This will return the value entered by the user in the input box. You can also use the "handles" structure to access the values of each input in the matrix.

4. Can I validate the inputs in the matrix of edit text inputs?

Yes, you can validate the inputs in the matrix of edit text inputs by using the "uicontrol" function and specifying the "callback" property. In the callback function, you can perform any necessary validation and display an error message if the input does not meet the requirements.

5. How do I update the values in the matrix of edit text inputs?

To update the values in the matrix of edit text inputs, you can use the "set" function and specify the tag of the input and the new value you want to assign to it. You can also use the "handles" structure to access and update the values of each input in the matrix.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
Back
Top