Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Laboratory work 5.1eng.doc
Скачиваний:
0
Добавлен:
01.07.2025
Размер:
3.47 Mб
Скачать

Decision of the systems of linear equations

The system is Given from three equations with three unknown:

Task 20.

Enter coefficients at unknown in a matrix A, and right parts in the vector b. Find a decision as a result from the division of matrix A on the vector b.

>> x = A \ b

Three-dimensional graphic arts

Every point in space is characterized by three co-ordinates. Set of points, belongings to one line in space it is needed to set as three vectors (the first must contain the first co-ordinates of these points, second - second, third - third). These three vectors given on the input of function plot3, which will carry out planning of corresponding three-dimensional line on a plane and will build a resulting image.

The so, for example, next fragment of koda will build an image, presented on a picture on the right.

>> t=0: pi/50:10*pi;

>> x=sin(t);

>> y=cos(t);

>> plot3(x, y, t);

>> grid on

If on the input of function plot3 to give not three vectors, and three matrices of identical size, the system MatLab will build family of lines of crossing of surface with a set parallel to each other of planes which are besides parallel to one of co-ordinate planes.

At the construction of three-dimensional chart for displaying of two variables function follows:

  1. to create matrices with the co-ordinates of grid on the function definition rectangular range;

  2. to calculate a function in the sites of grid and write down the got values in a matrix;

  3. to use one of graphic functions of Matlab;

  4. to inflict additional information on a chart.

For example, for the construction of chart of function on the range of definition as a square , it is necessary:

  1. At the beginning to break up this square an even grid, that done by means of function meshgrid:

>> [x,y]=meshgrid(0:0.2:1,0:0.2:1)

x =

0 0.2000 0.4000 0.6000 0.8000 1.0000

0 0.2000 0.4000 0.6000 0.8000 1.0000

0 0.2000 0.4000 0.6000 0.8000 1.0000

0 0.2000 0.4000 0.6000 0.8000 1.0000

0 0.2000 0.4000 0.6000 0.8000 1.0000

0 0.2000 0.4000 0.6000 0.8000 1.0000

y =

0 0 0 0 0 0

0.2000 0.2000 0.2000 0.2000 0.2000 0.2000

0.4000 0.4000 0.4000 0.4000 0.4000 0.4000

0.6000 0.6000 0.6000 0.6000 0.6000 0.6000

0.8000 0.8000 0.8000 0.8000 0.8000 0.8000

1.0000 1.0000 1.0000 1.0000 1.0000 1.0000

  1. Then to calculate the values of function in the sites of this grid. It is done by set of command:

>> z=x.^2+y.^2

z =

0 0.0400 0.1600 0.3600 0.6400 1.0000

0.0400 0.0800 0.2000 0.4000 0.6800 1.0400

0.1600 0.2000 0.3200 0.5200 0.8000 1.1600

0.3600 0.4000 0.5200 0.7200 1.0000 1.3600

0.6400 0.6800 0.8000 1.0000 1.2800 1.6400

1.0000 1.0400 1.1600 1.3600 1.6400 2.0000

  1. By means of command of mesh to build a chart as a framework surface:

>> mesh(x, y, z)

For more exact construction it is necessary to choose more shallow step of construction of grid - 0.05.

Task 21.

Build the chart of function

on the rectangular range of definition in six subwindows (subplot), using different graphic functions, setting a header to every chart (title).

Function

Action

mesh(x, y, z)

builds a framework surface

meshc(x, y, z)

builds a framework surface and places the xy lines of level of function (lines of constancy of function) on a plane

contour3

builds a surface, consisting of lines of level

surf

builds a framework surface and inundates every cage of surface a certain color

surfc

builds a framework surface, inundates every cage of surface a certain color and places the xy lines of level of function on a plane

surfl

builds the lighted up surface

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]