ebook img

MATLAB Graphical Programming: Practical hands-on MATLAB solutions PDF

195 Pages·2014·8.53 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview MATLAB Graphical Programming: Practical hands-on MATLAB solutions

L ó p e z MATLAB Graphical Programming MATLAB enables you to work with its graphics capabilities in almost all areas of the experimental sciences and engineering. The commands that MATLAB implements in job related graphics are M quite useful and are very efficient. MATLAB Graphical Programming is a reference work designed A to take you through implementing two and three dimensional graphics using MATLAB’s graphics functions’ capabilities, using syntax examples and graphs. Furthermore, you will learn to create T surfaces, volume graphs and more for application in a wide range of fields. L MATLAB has functions for working with two-dimensional and three-dimensional graphics, A statistical graphs, curves and surfaces in explicit, implicit, parametric and polar coordinates. B It also works perfectly with twisted curves, surfaces, volumes and graphical interpolation. G MATLAB Graphical Programming addresses all these issues by developing the following topics: r • Two dimensional graphics a • Statistical graphics p • Curves in explicit coordinates h • Curves in parametric coordinates i c • Curves in polar coordinates a • Logarithmic and semi-logarithmic plots l • Bar graphs and histograms sectors P • Three-dimensional graphics • Twisted curves and surfaces r o • Graphs of surfaces, meshes and contours g • parametric surfaces r • Viewing volumes and specialized graphics a • Special commands for graphics m You will learn to: m • Program MATLAB to take advantage of its graphics functionality • Create two and three dimensional graphics in MATLAB i n • Create volumetric and other specialized graphics g ISBN 978-1-4842-0317-0 53999 Shelve in Applications/Mathematical & 9781484203170 Statistical Software For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to access them. Contents at a Glance About the Author �����������������������������������������������������������������������������������������������������������������ix About the Technical Reviewer ���������������������������������������������������������������������������������������������xi Introduction �����������������������������������������������������������������������������������������������������������������������xiii ■ Chapter 1: MATLAB Introduction and the Working Environment ���������������������������������������1 ■ Chapter 2: Two-Dimensional Graphics� Statistics Graphics and Curves in Explicit, Parametric and Polar Coordinates �����������������������������������������������������������������������������������27 ■ Chapter 3: Three-Dimensional Graphics, Warped Curves and Surfaces, Contour Graphics �������������������������������������������������������������������������������������������������������������51 ■ Chapter 4: Display Volumes and Specialized Graphics ���������������������������������������������������73 ■ Chapter 5: Graphics Special Commands �������������������������������������������������������������������������99 ■ Chapter 6: Polynomials and Graphics Interpolation ������������������������������������������������������123 ■ Appendix A: Numbers, Variables, Operators and Functions Used in Graphics Programming� �������������������������������������������������������������������������������������������������137 iii Introduction MATLAB is a platform for scientific computing that can work in almost all areas of the experimental sciences and engineering. This software allows you to work in the field of graphics, featuring some pretty extensive capabilities. The commands and functions that are implemented in MATLAB and other toolkits working with MATLAB are robust, accurate and very efficient. MATLAB Graphical Programming is a reference for many MATLAB functions for working with two-dimensional and three-dimensional graphics, statistical graphs, curves and surfaces in explicit, implicit, parametric and polar coordinates. A wide array of short examples and exercises implement twisted curves, surfaces, meshes, contours, contours, volumes and graphical interpolation showing both the script and the result. The book begins by treating two-dimensional graphics and statistical graphics. Then it delves into the graphic representations of curves in explicit coordinates, parametric curves and curves in polar coordinates. The next block of content is devoted to the log charts and bar charts, pies and histograms. Then we move into three-dimensional graphics, starting with warped curves, contours and surfaces charts, grids and contours. It then analyzes graphs of surfaces in explicit coordinates and parametric coordinates. It also devotes a portion of the content to display volumes, specialized graphics and special graphics commands in the MATLAB environment. Finally graphics for interpolation and polynomial fit are developed and special graphics commands are presented. If you are new to MATLAB or need a basic reference to MATLAB functions that are used in the book, then you may want to read the appendix to get up to speed fast. It can also be used as a reference to more general MATLAB functions for quick look up. xiii Chapter 1 MATLAB Introduction and the Working Environment 1.1 MATLAB Introduction MATLAB is a platform for scientific calculation and high level programming through an interactive environment that allows for accurate resolution of complex calculation tasks more quickly than with traditional programming languages. It is the calculation platform of choice currently used in the sciences and engineering and in many technical business areas. MATLAB is also a high-level technical computing interactive environment for algorithm development, data visualization, data analysis and numerical calculations. MATLAB is suitable for solving problems of technical calculation using optimized algorithms that for the end user are easy to use commands. It is possible to use MATLAB in a wide range of applications including mathematical calculus, algebra, statistics, econometrics, quality control, time series, processing of signals and images, communications, design of control systems, test and measurement systems, modeling and financial analysis, computational biology, etc. The complementary toolsets called toolboxes (collections of MATLAB functions for special purposes, which are available separately) extend the environment of MATLAB allowing you to solve special problems in different areas of application. It is possible to integrate MATLAB code in with other languages and applications, in addition to the distributed algorithms and applications that are developed using MATLAB. Taken together, the functions, commands and programming capabilities of the MATLAB ecosystem are a truly amazing collection. Following are the important graphics related features of MATLAB: • A high level technical calculation language • A development environment for managing code, files, and data • Interactive tools for exploration, design and iterative solutions • Mathematical functions for linear algebra, statistics, Fourier, filtering, optimization, and numerical integration analysis • Two-dimensional and three-dimensional graphics functions for visualizing data • Tools to create custom graphical user interfaces • Functions to integrate the algorithms based on MATLAB applications with external languages, such as C/C++, Fortran Java, Microsoft .Net, Excel and others. The MATLAB development environment allows you to develop algorithms and analyze data, display data files and manage projects in an interactive mode featuring the Command Window, which is the hub of activity and is shown in Figure 1-1. 1 Chapter 1 ■ MatLaB IntroduCtIon and the WorkIng envIronMent Figure 1-1. 1.1.1 Algorithms and Applications Development MATLAB provides high-level programming language and development tools with which it is possible to develop and utilize algorithms and applications quickly. The MATLAB language includes vector and matrix operations that are fundamental to solve scientific and engineering problems, streamlined for both development and execution. With the MATLAB language, it is possible to program and develop algorithms faster than with traditional languages because it is not necessary to perform low level administrative tasks, such as specifying data types and allocating memory. In many cases, MATLAB eliminates the need of ‘for’ loops using a technique called vectorization. As a result, a line of MATLAB code usually replaces several lines of C or C++ code. At the same time, MATLAB offers all the features of traditional programming languages, including arithmetic operators, control flow, data structures, data types, object-oriented programming and debugging. An algorithm for modulation of communications that generates 1024 random bits, performs modulation, adds complex Gaussian noise and graphically represents the result is represented in Figure 1-2. All in just lines of code in MATLAB. 2 Chapter 1 ■ MatLaB IntroduCtIon and the WorkIng envIronMent Figure 1-2. MATLAB enables you to execute commands or groups of commands one at a time, with no compile or link, to achieve the optimal solution. To quickly execute complex vector and matrix calculations, MATLAB uses libraries optimized for the processor. For many of its calculations, MATLAB generates instructions into machine code using JIT (Just-In-Time) technology. Thanks to this technology, which is available for most platforms, execution speeds are much faster than with traditional programming languages. MATLAB includes development tools, which help efficiently implement algorithms. The following are some of them: • MATLAB Editor – With editing functions and standard debugging offerings such as setting breakpoints and step by step simulations • M-Lint Code Checker – Analyzes the code and recommends changes to improve the performance and maintenance (Figure 1-3) Figure 1-3. 3 Chapter 1 ■ MatLaB IntroduCtIon and the WorkIng envIronMent • MATLAB Profiler – Records the time that it takes to execute each line of code • Directory Reports – Scans all files in a directory and creates reports about the efficiency of the code, the differences between files, dependencies of the files and code coverage You can also use the interactive tool GUIDE (Graphical User Interface Development Environment) to design and edit user interfaces. This tool allows you to include pick lists, drop-down menus, push buttons, radio buttons and sliders, as well as MATLAB diagrams and ActiveX controls. You can also create graphical user interfaces by means of programming using MATLAB functions. You can also expose figures or MATLAB algorithms on the web. Figure 1-4 shows the analysis of wavelets in the tool user interface using GUIDE (above) and the interface (below) completed. Figure 1-4. 4 Chapter 1 ■ MatLaB IntroduCtIon and the WorkIng envIronMent 1.1.2 Data Access and Analysis MATLAB supports the entire process of data analysis, from the acquisition of data from external devices and databases, pre-processing, visualization and numerical analysis, up to the production of results in presentation quality. MATLAB provides interactive tools and command line operations for data analysis, which include: sections of data, scaling and averaging, interpolation, thresholding and smoothing, correlation, analysis of Fourier and filtering, search for one-dimensional peaks and zeros, basic statistics and curve fitting, matrix analysis, etc. Figure 1-5 shows a diagram that shows a curve adjusted to atmospheric pressure differences averaged between Easter Island and Darwin in Australia. Figure 1-5. In terms of access to data, MATLAB is an efficient platform for access to data files, other applications, databases and external devices. You can read data stored in most known formats, such as Microsoft Excel, ASCII text files or binary files of images, sound and video, and scientific archives such as HDF and HDF5 files. The binary files for low level I/O functions allow you to work with data files in any format. Additional features allow you to view web pages and XML data. It is possible to call other applications and languages, such as C, C++, COM, DLLs, Java, Fortran, and Microsoft Excel objects and access FTP sites and web services. Using the Database Toolbox, you can access ODBC/JDBC databases. 5 Chapter 1 ■ MatLaB IntroduCtIon and the WorkIng envIronMent 1.1.3 Data Visualization All graphics functions necessary to visualize scientific and engineering data are available in MATLAB. MATLAB includes features for representation of two-dimensional and three-dimensional diagrams, three-dimensional volume visualization, tools to create diagrams interactively and the possibility of exporting to the most popular graphic formats. It is possible to customize diagrams adding multi-axes, change the colors of the lines and markers, add annotations, LaTeX equations, legends and other plotting options. Vectors functions represented by two-dimensional diagrams can be viewed to create: • Diagrams of lines, area, bars and sectors • Direction and velocity diagrams • Histograms • Polygons and surfaces • Dispersion bubble diagrams • Animations Figure 1-6 shows linear plots of the results of several tests of emissions of a motor, with a curve fitted to the data. Figure 1-6. MATLAB also provides functions for displaying two-dimensional arrays, three-dimensional scalar data and three-dimensional vector data. It is possible to use these functions to visualize and understand large amounts of multidimensional data that is usually complex. It is also possible to define the characteristics of the diagrams, such as the orientation angle of the camera, perspective, lighting effects, the location of the source of light and transparency. 3D diagramming features include: • Surface, contour and mesh • Diagrams of images • Cone, pastel, flow and isosurface 6

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.