Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

лаб 1 моделирование

.docx
Скачиваний:
8
Добавлен:
15.06.2023
Размер:
324.5 Кб
Скачать

Код:

clc,clear

x=1.001;

y=-10.7;

(log(sin(x*pi/8)) + x^2 + sqrt(2*x-2))/2^y

x=2+3i;

y=1-i;

(log(sin(x*pi/8)) + x^2 + sqrt(2*x-2))/2^y

Результат:

ans =

144.9280

ans =

-5.4745 + 4.6575i

Код:

clc,clear

X=5:-3:-5;

atan(X)

X.^3

dot(X,X)

Результат:

ans =

1.3734 1.1071 -0.7854 -1.3258

ans =

125 8 -1 -64

ans =

46

Код:

clc,clear

A = [

1 2 3;

4 5 6;

7 8 9

];

B = [ 2 6 8;

6 11 0.5];

C = [ 13 87 76 45 44];

%A*B

D = cat(1,cat(2,A,B'),C)

D2=D;

D(:,4:5)=[];

D(4,:)=[]

D2;

D2(2,:)=[];

D2(3,:)=[];

D2(:,2)=[];

D2(:,3)=[]

clear

X = [2 5 -8;

5 6 3;

4 -5 -1

];

Y = [8; 12; 23];

inv(X)*Y

Результат:

D =

1.0000 2.0000 3.0000 2.0000 6.0000

4.0000 5.0000 6.0000 6.0000 11.0000

7.0000 8.0000 9.0000 8.0000 0.5000

13.0000 87.0000 76.0000 45.0000 44.0000

D =

1 2 3

4 5 6

7 8 9

D2 =

1.0000 3.0000 6.0000

7.0000 9.0000 0.5000

ans =

4.1636

-1.1354

-0.6687

Код:

clc,clear

x=-10:1:10;

y=x-sin(3*x);

plot(x,y)

title('y=x-sin(3*x)')

clear

figure

fplot(@(x)(x-sin(3*x)),[-10 10],1)

title('y=x-sin(3*x) fplot')

x=-10:1:10;

y=x/sin(x);

figure

plot(x,y)

title('y=x/sin(x)')

clear

figure

fplot(@(x)(x/sin(x)),[-10 10])

title('y=x/sin(x) f plot')

clear

figure

x=0:0.01:2*pi;

y=x.*sin(5*x);

polar(x,y)

title('y=x*sin(5*x) x=0:0.01:2*pi')

figure

x=-2*pi:0.01:2*pi;

y=x.*sin(5*x);

polar(x,y)

title('y=x*sin(5*x)x=-2*pi:0.01:2*pi')

clear

figure

grid on

t=0:0.01:2*pi;

x=-3+5*sin(t);

y=2+4*cos(t);

plot(x,y)

title('ellipse')

figure

ezplot('(x+3)^2/25 + (y-2)^2/16-1')

title('ellipse ezplot')

Результат:

Код:

clc,clear

t = -5:0.1:5;

x=sin(t);

y=2*cos(2*t);

plot(x,y)

clear

figure

[x, y] = meshgrid(0:.1:3, 0:.1:3);

z=(x.^2+y.^2)./(5.*x.*y) + log(x+y);

mesh(z)

Результат:

Код скрипта:

clc,clear

task7_fac(-1)

task7_fac(3)

task7_row(16)

Код функции факториала:

function res = task7_fac(n)

if(n>0) res=factorial(n);

end

if(n<=0) disp('Invalid input (zero or negative)')

end

end

Код функции суммы ряда:

function res = task7_row(N)

res=0;

mes = 'Enter precision:';

eps=input(mes);

n=1;

%f=1/n^(N+1)

while eps<=abs(1/n^(N+1))

res = res + 1/n^(N+1);

n=n+1;

end

end

Результат:

Invalid input (zero or negative)

ans =

6

Enter precision: 0.0001

ans =

1

Соседние файлы в предмете Моделирование