Chapter 6: Conclusions and further development of the research
2. Changes in the Third Edition of MATLAB
Some of the major changes include:
Case-sensitive function and directory names on all platforms. Function handles.
The use of an end statement at the end of functions. Nested functions.
Math operations with single and integer data types.
Major revision of the GUI code, including the addition of panels, button groups, and toolbars. The code auto- generated by guide has been totally changed. Frames have been deprecated.
Major revisions to programming tools, such as the addition of conditional breakpoints and the mlint tool to check for poor programming practices within an M-file.
2.1. The advantages of MATLAB for technical programming
MATLAB has many advantages compared to convectional computer languages for technical problem solving. These include:
1. Ease of Use
MATLAB is an interpreted language, like many versions of Basic. Like Basic, it is very easy to use. The program can be used as a scratch pad to evaluate expressions typed at the command line, or it can be used to execute large prewritten programs. Programs may be easily written and modified with the built-in integrated development environment and debugged with the MATLAB debugger. Because the language is so easy to use, it is ideal for educational use and for the rapid prototyping of new programs.
Many program development tools are provided to make the program easy to use. They include an intergraded editor/debugger, on-line documentation and manuals, a workspace browser, and extensive demos.
2. Platform Independence
MATLAB is supported on many different computer systems, providing a large measure of platform independence. At the time of this writing, the language is supported on Windows NT/2000/XP, Linux, UNIX, and the Macintosh. Programs written on any platform and the data files written on many platforms written in MATLAB can migrate to new platforms when the needs of the user change.
3. Pre-Defined Functions
MATLAB comes complete with an extensive library of predefined functions that provide tested and prepackaged solutions to many basic technical tasks. For example, suppose that you are writing a program that must calculate the statistics associated with an input data set. In most languages, you would need to write subroutines of functions to implement calculations such as the arithmetic mean, standard deviation, median among others. These and hundreds of other functions are built right into the MATLAB language, making your job much easier.
Antonopoulos John – PHD Research Page 167 Unlike other computer languages, MATLAB has many integral plotting and imaging commands. The plots and the images can be displayed on any graphical output device supported by the computer on which MATLAB is running. This capability makes MATLAB an outstanding tool for visualizing technical data.
5. Graphical user interface
MATLAB includes tools that allow a program to interactively construct a graphical user interface (GUI) for his or her program. With this capability, the programmer can design sophisticated data analysis programs that can be operated by relatively-inexperienced users.
6. MATLAB Compiler
MATLAB‘s flexibility and platform independence are achieved by compiling MATLAB programs into a device-independent p-code and then interpreting the p- code instructions at run-time. This approach is similar to that used by Microsoft‘s Visual Basic Language. Unfortunately, the resulting programs can sometimes execute slowly because the MATLAB code is interpreted rather than compiled.
A separate MATLAB compiler is available. This compiler can compile a MATLAB program into a true executable that runs faster than the interpreted code. It is a great way to convert a prototype MATLAB program into an executable suitable for sale and distribution to users.
MATLAB is a huge program with an incredibly rich variety of functions. Even the basic version of MATLAB without any toolkits is much richer than other technical programming languages. There are more than 1000 functions in the basic MATLAB product alone, and the toolkits extend this capability with many more functions in various specialties.
2.2.
Disadvantages of MATLAB
MATLAB has two principal disadvantages. The first is that it is an interpreted language and therefore can execute more slowly than compiled languages. This problem can be mitigated by properly structuring the MATLAB program, and by the use of the MATLAB compiler to compile the final MATLAB program before distribution and general use.
The second disadvantage is cost: a full copy of MATLAB is five to ten times no more expensive than a conventional C of Fortran compiler. This relatively high cost is more than offset by the reduced time required for an engineer or scientist to create a working program, so MATLAB is cost-effective for businesses. However, it is too expensive for most individuals to consider purchasing. Fortunately, there is also an inexpensive Student Edition of MATLAB, which is a great tool for students wishing to learn the language. The Student Edition of MATLAB is essentially identical to the full edition.
A graphical user interface (GUI) is a pictorial interface to a program. A good GUI can make programs easier to use by providing them with a consistent appearance, and with intuitive controls such as pushbuttons, edit boxes, list boxes, sliders, and menus. The GUI should behave in understandable and predictable manner, so that a user knows what to expect when he or she performs an action. For example, when a mouse click occurs on a pushbutton, the GUI should initiate the action described on the label of the button.
Antonopoulos John – PHD Research Page 168 This chapter contains an introduction to the basic elements of the MATLAB GUIs. It does not contain a complete description of components or GUI features, but it does provide us with the basics required to create functional GUIs for your programs.
2.3.
How a graphical user interface works
A graphical interface provides the user with a familiar environment in which to work. It contains pushbuttons, toggle buttons, lists, menus, text boxes, and so forth, all of which are already familiar to the user, so that he or she can concentrate on the purpose of the application instead of the mechanics involved in doing things. However, GUIs are harder for the programmer, because a GUI-based program must be prepared for mouse clicks (or possibly keyboard input) for any GUI element at any time. Such inputs are known ―aw‖ events, and a program that responds to events is said to be event driven.
The three principal elements required to create a MATLAB Graphical User Interface are:
1. Components. Each item on a MATLABGUI (e.g., pushbuttons, labels, edit boxes) is a graphical component. The types of components include graphical controls (pushbuttons, toggle buttons, edit boxes, lists, sliders, etc) static elements (text boxes), menus, toolbars and axes. Graphical controls and text boxes are created by the function uicontrol, and menus are created by the functions uimenu and uicontextmenu. Toolbars are created by function uitoolbar. Axes, which are used to display graphical data, are created by the function axes.
2. Containers. The components of a GUI must be arranged within a container, which is a window on the computer screen. The most common container is a figure. A figure is a window on the computer screen that has a title bar along the top, and that can optionally have menus attached. In the past, figures have been created automatically whenever data was plotted. However, empty figures can be created with the function figure, and they can be used to hold any combination of components and other containers.
The other types of containers are panels
3. Callbacks. Finally, there must be some way to perform an action if a user clicks a mouse on a button or types information on any keyboard. A mouse click or a key press is an event, and the MATLAB program must respond to each event if the program is to perform its function. For example, if a user clicks on a button to be executed. The code executed implements the function of the button to be executed. The code executed in response to an event is known as a callback. There must be a callback to implement the function of each graphical component on the GUI.
As mentioned in advantage 6, the compiler can transform the program into an independent program installed into any computer. In order to do this, besides the
Antonopoulos John – PHD Research Page 169 compiler, another program with the extension .exe is necessary which will install into the computer/client all the necessary libraries.
For the needs of this research a graphical interface was developed in which the user can perform readings with the novel hardware developed, but also to perform calculations in the signals and to compare them with reference signals.