ALWAYS plan your code ahead. This can be done by creating pseudo code, flow charts, or chicken scratch notes of what you will program.You need to have a good idea of what you are going to program before you even start. GUIs are to complicated to program just by gut feeling ?Analysts report that as
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
1. How to program MATLAB GUIs A 5 step process
Prepared by Maxwell Cohen
2. ALWAYS plan your code ahead. This can be done by creating pseudo code, flow charts, or chicken scratch notes of what you will program.
You need to have a good idea of what you are going to program before you even start. GUIs are to complicated to program just by gut feeling
“Analysts report that as many as 71 percent of software projects that fail do so because of poor requirements management, making it the single biggest reason for project failure—bigger than bad technology, missed deadlines or change management fiascoes.”
- CIO Magazine, November 2005
An ounce of prevention is worth a pound of cure.
-Benjamin Franklin Before we start
3. LOOK AT THIS COOL FLOWCHART Prof. Purzer , Prof. Knutson , and Roger Rovekamp have developed a great model on how to create MATLAB code this can be found on blackboard in “Template Files”
4. Now Back to the GUIs “If you can't describe what you are doing as a process, you don't know what you're doing.“ W. Edwards Deming (Statistical Quality Control Expert)
5. Before you can make any changes or do any calculations you need to retrieve data from the GUI this is done by get command
When you are working inside the callback function of a GUI component you would type
var = get(hObject, 'PropertyName')
When you are working in any other function you need to type
var = get(handles.Componentname#,'PropertyName')
NOTE: 'PropertyName' should be replaced with ‘String’ when you are reading text or ‘Value’ when you are getting the state of a component such as a radio button
NOTE: Use var = str2num(var) to convert var into a number.
6. Check to make sure that the variables that you are working with is what you expected use an if statement
if ~isempty(str2num(str)) % returns true if str is just numbers and no letters.
if strcmp(str1,str2) % returns true if str1 and str2 are the same.
7. Do whatever calculations that you need to do or run whatever functions you need to do.
NOTE: Variables that are a part of the handles structure need to be referred to as handles.var
8. Based on your calculations or data validation you might need to update the GUI, to do this you use the set command.
When you are working inside the callback function of a GUI component you would type…
set(hObject, ‘PropertyName’, PropertyValue)
When you are working in any other function you need to type…
set(handles.Componentname#, ‘PropertyName’, PropertyValue)
NOTE: ‘PropertyName’ needs to be a property of the GUI component you can get a list of properties of each GUI component by double clicking in guide on a component.
NOTE: Use var = num2str(var) to convert var into a string.
Update the GUI
9. Include this as the last line of the function to insure that any changes that you make in the functions are able to pass to other functions
Return handles back to the program
10. Getting very concern until runtime