$24
Matlab provides GUI components to facilitate more interactive usage of its program during run time. In general the users of Matlab program is expected to be scientists or programmers, who are professional in its usage. However for some complicated calculations involving many variables, or in certain instances that the application is intended for some rapid prototyping, it might have the need for some user interface elements which provide more interactive testing of parameters.
The following is a condensed description of GUI in Matlab. For more detail discussions, please check the help documents by selecting “Documentation” under the Help menu in Matlab. The GUI discussions are located under the content Tab, with MATLAB title, with the topic “GUI Building”.
Matlab UI elements
Each component, and the GUI itself, is associated with one or more user-written routines known as callbacks. The execution of each callback is triggered by a particular user action such as a button push, mouse click, selection of a menu item, or the cursor passing over a component. You, as the creator of the GUI, provide these callbacks.
This kind of programming is often referred to as event-driven programming. In event-driven programming, callback execution is asynchronous, controlled by events external to the software. In the case of MATLAB® GUIs, these events usually take the form of user interactions with the GUI.
The writer of a callback has no control over the sequence of events that leads to its execution or, when the callback does execute, what other callbacks might be running simultaneously.
In Matlab, basically you have two ways to create a user interface – by an interactive tools called GUIDE, or through program command . In this assignment, you are required to build a simple user interface to a design program which can calculate the optimized value of some design parameters.
By typing “guide” under Matlab, you will be brought to the GUI design program, with intuitive design, the program enable you to quickly write a GUI program that accept and return parameters in Matlab.
1'
'
CSCI1050'Assignment'
'
Problem Description
A fenced enclosure consists of a rectangle of length L and width W, and a right-angled triangle with base D, as shown below. The enclosure is to be built to have an area A of 1600 ft2. The cost of the fence is $40 per foot for triangle part, and $30 per foot for the rectangle part because of different materials. Use the fminbnd function to determine the values of L, W, and D required to minimize the total cost of the fence. Also compute the minimum cost. (Note: W2 = 2D2 and Area of triangle = D2 / 2). You should write a Matlab program with a GUI similar to that below.
W"
L"
D"
D"
You should display the results of the computation using an interface similar to the following layout
The user is required to input the area of the fence through the text box near the “Fence Area” label. A push button is located on the right for the user to initiate the calculation.
After pressing the “Calculate” button, your program should display the results in the text box correct to 1 decimal place, as shown below for the input of 1600 as the area.
2'
'
CSCI1050'Assignment'
'
Note that the result should display blank space in case irrelevant values are being input e.g. 0 or negative values. However you may assume that the user will only input numeric values here.
Submission:
1. Pack all your Matlab script files into a single archive and submit the file via our eLearning Assignment Submission System
<http://elearn.cuhk.edu.hk>
2. If you submit multiple times, ONLY the content and time-stamp of the latest one would be counted.
3. Remember to do your submission before 23:59 p.m. of the due date.
'
3'
'