Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Best way for GUI

Subject: Best way for GUI

From: Ali

Date: 5 Mar, 2009 13:54:01

Message: 1 of 6

Hi all,
A GUI is providing user:
1. Selection from prelisted cars
2. Selection from prelisted colors for car
when car type and color is selected from User, some calculations are done by MatLab.

I have to enhance this project.
1. Providing option for user insertion of new types of cars.
2. Providing option for user insertion of new types of color.

Once data for new car is entered/saved by user, it should be store in 'Prelisted cars' and available for other users to use it.
The data of new car type and color comprising approx. 30 variables which are further used to make very complex calculations.

What I want to ask is what is the best way to get data from User:
1. Directly from MatLab GUI
2. Through Excel sheet and import data to MatLab (would it require Excel toobox?)
3. Make user interface through .Net and connect it to MatLab.
4. Anyother proposal?

Regards,
Raza

Subject: Best way for GUI

From: Roland Neumann

Date: 9 Mar, 2009 13:37:01

Message: 2 of 6

You're serious?! Just put a matlab gui with 2 selection fields together.

Subject: Best way for GUI

From: ImageAnalyst

Date: 9 Mar, 2009 13:52:18

Message: 3 of 6

"Ali" <smiling.st...@live.com>, Raza:
Under, or beside, the listbox of car types I would place a button that
has caption "Add new car type..." When the user clicks that it brings
up another GUI with various ways (checkboxes, radio buttons, sliders,
edit text fields, etc.) of setting the 30 parameters for that car.
When they click OK then it saves out all that information for that car
into a database, such as Excel, a mat file, a text file, or a true
database. Do you already have that information somewhere? I'm
assuming not. If you do, then just read it in from the file or
database. Then back in the main GUI, take the name and append it to
the listbox containing the car types.
Regards,
ImageAnalyst

Subject: Best way for GUI

From: Ali

Date: 9 Mar, 2009 14:13:01

Message: 4 of 6

Thank you very much for your reply. I was waiting for it.
I understand your opinion. I have just 2 questions in this procedure:
The data of prelisted cars are present in .m file in structure form. The switching between car data is done with if / elseif loop.

if option==1 % car no. 1 gives option=1
    vars = struct( ...)
elseif option==2
vars=struct(...) % car no. 2 gives option=2
.
.
.
elseif option==9
vars=struct(...) % car no. 9 gives option=3
end
Now there are fix elseif present in code. How 'elseif' automatically add before 'end' for new car type.

Any suggestions?

2nd questions, how new cars can automatically add into GUI list?


 
ImageAnalyst <imageanalyst@mailinator.com> wrote in message <0266064a-83f4-40b3-a34b-d0ca0eb36383@f37g2000vbf.googlegroups.com>...
> "Ali" <smiling.st...@live.com>, Raza:
> Under, or beside, the listbox of car types I would place a button that
> has caption "Add new car type..." When the user clicks that it brings
> up another GUI with various ways (checkboxes, radio buttons, sliders,
> edit text fields, etc.) of setting the 30 parameters for that car.
> When they click OK then it saves out all that information for that car
> into a database, such as Excel, a mat file, a text file, or a true
> database. Do you already have that information somewhere? I'm
> assuming not. If you do, then just read it in from the file or
> database. Then back in the main GUI, take the name and append it to
> the listbox containing the car types.
> Regards,
> ImageAnalyst

Subject: Best way for GUI

From: Image Analyst

Date: 9 Mar, 2009 17:32:03

Message: 5 of 6

"Ali" <smiling.stone@live.com>:
Somehow you must know what specific structure you're going to assign. For example if they click the listbox item for car #5, you have to know that you need to assign structure #5 and not structure #1 or #2 or any other structure. So given that, you must have the structure, and the question is: how can you have a variable number of items to select from (because an "if" statement can't do it). One answer is that you might try a switch() statement but really that might not even help because you still need to know which "case" to go into. So it comes down to: how do you have all your structures stored? Are they all one index of a larger parent structure so that you can just use the index to get the structure you're interested in? If so, you don't even need a swtich or an if. Just index into it, like
thisCarsStructure = parentStructure(5);

For the second question, you have to ask the user for the new car type, then you have to get all the items in the listbox, add that new item to it, and finally put the list back. So the pseudo code would go something like
    userResponse = inputdlg('Enter the new car type')
    % Get a list of everything currently in the listbox.
    ListOfCars = get(handles.lstCarList, 'string');
    % Append the car name they just now typed in.
    % Note: I don't know the syntax off the top of my head.
    % Maybe you have to use the strvcat() function instead.
    ListOfCars = {ListOfCars ; userResponse};
    % You can sort() the list alphabetically here if you want.
    % Send list back to the listbox.
    set(handles.lstCarsList, 'String', ListOfCars);
You might have to tweak the above code to get it to work perfectly.
Good luck,
ImageAnalyst

Subject: Best way for GUI

From: Ali

Date: 10 Mar, 2009 10:44:02

Message: 6 of 6

> ImageAnalyst

Thank you Mr. Analyst!
I am working on it. Hope I get no further problem.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us