1 / 10

How to program MATLAB GUIs

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

dore
Télécharger la présentation

How to program MATLAB GUIs

An Image/Link below is provided (as is) to download presentation 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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. How to program MATLAB GUIs A 5 step process Prepared by Maxwell Cohen http://web.ics.purdue.edu/~cohenm/fye.html

    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 failurebigger 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. Get data

    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. Validate data

    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 Calculate data

    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 guidata(hObject, handles); Return handles back to the program

    10. Getting very concern until runtime

More Related