Вы находитесь на странице: 1из 3

Course: Numerical Analysis Tutorial 1: Introduction to MATLAB and MATLAB Usage && Matrix Manipulation Date: 20. 02.

2013

Goals and Objectives:


1. To help students learn quickly the first steps in MATLAB 2. To give short description and usage of MATLAB 3. To introduce matrices, arrays and manipulation with arrays and matrices

Theoretical Background The accent of this tutorial is learning by doing". Working through the examples will make students feeling for the way that MATLAB functions. In this tutorial, it will be described how MATLAB works with basic numerical expressions, mathematical formulas matrices and arrays. The name MATLAB stands for MATrix LABoratory. MATLAB was created at first to give simple access to matrix software developed by the LINPACK (linear system package) and EISPACK (Eigen system package) projects. MATLAB is a high-performance language for computing. It relates computation, visualization, and programming environment. In addition, MATLAB is a contemporary programming language environment: it has modern data structures, contains built-in editing and debugging tools, and supports object-oriented programming. These factors make MATLAB a brilliant instrument for education and investigation. MATLAB has numerous advantages compared to traditional computer languages (e.g., C, FORTRAN) for solving technical problems. It has leading built-in routines that facilitate a very broad selection of computations. It also has simple to utilize graphics commands that build the visualization of results directly available. Particular applications are collected in packages referred to as toolbox. There are toolboxes for signal processing, symbolic computation, control theory, simulation, optimization, and several other fields of applied science and engineering. In this section we will illustrate how to apply different BUILT-IN MATLAB functions on real-life problems. The following topics are discussed: plotting, simple vector crating and manipulation .

Exercises 1. Give values to variables a and b on the command line, e.g. a = -8 and b = 40. a. Write some statements to find the sum, difference, product and quotient of a and b. b. Write the same statement in new M-file and compare the results

2. Plot trigonometric functions in MATLAB. x=0:0.001.6*pi y = sin(2*pi*x) plot(x, y, r); grid minor; 3. Load any sound and run it. >> load laughter <Enter> >> sound(y,Fs) <Enter> 4. Load file called Earth and visualize it >> load earth >> image(X); colormap(map) >> axis image 5. Design Famous Mexican Hat >> [x y ] = meshgrid(-8 : 0.5 : 8); >> r = sqrt(x.2 + y.2) + eps; >> z = sin(r)./r; >> mesh(z); <Enter> <Enter> <Enter> <Enter> <Enter> <Enter> <Enter>

When execution completes, the variables remain in the workspace. To see a listing of them, enter whos at the command prompt. Note: The MATLAB editor is both a text editor r specialized for creating M-files and a graphical MATLAB debugger. The MATLAB editor has numerous menus for tasks such as saving, viewing, and debugging. Because it performs some simple checks and also uses color to differentiate between various elements of codes, this text editor is recommended as the tool of choice for writing and editing M-les.

A few useful math functions: sqrt(x) square root sin(x) sine function. See also cos(x), tan(x), etc. exp(x) exponential log(x) natural log log10(x) common log abs(x) absolute value mod(x) modulus

factorial(x) factorial function floor(x) round down. See also ceil(x), round(x). min(x) minimum elements of an array. See also max(x). besselj(x) Bessel functions of first kind

Homework EXERCISE:

2x 3 y 4z 5
1. a. Solve the following problem: 3x 4 y 4 z 7 .

2 y 3z 2
b. Find minimum of [x,y,z]. c. Find maximun of [x,y,z]. d. Check if numbers x, y, z are Pitagora triplets.

2. Write simple M-File that will load any photo and plot it in MATLAB

Вам также может понравиться