How to use popup menu and uitable?

1.7k views Asked by At

I have a popup menu and a table. Popup menu is to select a generator that will be used by the user. For example if the user wants to use 2 generators, then the user may select '2 'on the popup menu. If the user select 2, then the table will be issued a 2 by 3 table. If users select three generators, then the table will be issued a 3 by 3 table. If users select four generators, then the table will be issued a 4 by 3 table and so on. My question is how i want this situation applies? What I mean is how to produce a 2 by 3 table when the user select '2' and 3 by 3 table when the user select '3' and so on?

For your info, My project is about economic dispatch. I have to build GUI using 4 generators and each of the generator have limit. So i have to make 2 uitables. So each generator user selected, then the user have to insert limit( in megawatt) for each generator(which is another table)

This is the example of my table(4 by 3):

      Alpha   Beta  Gamma

C1

C2

C3

C4

The equation for the generator is :

C1 = (Alpha) + (Beta)P + (Gamma)P^2

C2 = (Alpha) + (Beta)P + (Gamma)P^2

C3 = (Alpha) + (Beta)P + (Gamma)P^2

C4 = (Alpha) + (Beta)P + (Gamma)P^2

This is a table for the limit of each generator:

  Lower  Upper

C1

C2

C3

C4

The form of this table will be :

Lower < C1 < Upper

Lower < C2 < Upper

Lower < C3 < Upper

Lower < C4 < Upper

So when the user select '2', then it will popup the 2 by 3 table. How i want to do it? What is the code for it and how i want to call the table data into the pushbuttons? Well i already make 2 uitable figures and i already set the table properties like the row name n column name. But how i want to make it only 2 row only?

Please do help me on this.

1

There are 1 answers

0
eacousineau On

I'm in the process of learning MATLAB GUI too :P I haven't yet used any popups or modal dialogs, but using uitable() [ http://www.mathworks.com/help/techdoc/ref/uitable.html ] you can define your table and then adjust the properties [ http://www.mathworks.com/help/techdoc/ref/uitableproperties.html ]. For example, to have N rows, you would set your table's data, i.e.

set(table, 'Data', zeros(n, 3));

That would give you a n x 3 table.

I would start playing around with GUIDE to get a feel for it. However, GUIDE just seems too messy for me. After a while, I opted for using GridLayout [ http://www.mathworks.com/matlabcentral/fileexchange/29472-gridlayout ] and defining my own classes.