function Lab1 x2 zeros x1 zeros 300 10000 alpha -1 x1 x2 -1 for x1 x2

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function Lab1()
x2=zeros();
x1=zeros();
T = 300;
N = 10000;
h=T/N;
n=0:h:T;
c=3;
alpha=-1.1;
x1(c+1)=0.5; x2(c+1)=-1;
for k=1:c
x1(k)=0.5;
x2(k)=-1;
end
plot(x2(1),x1(1),'ro');
hold on
M=0.08;
t=0;
for k=c+2:length(n+c)
%для 1 ур:
past=exp(-t)+1;
x1(k)=x1(k-1)+x2(k-1)*h+alpha*x2(c + 1 + fix(t-past))*h;
%для 2 ур:
x2(k)=x2(k-1)+(M*x2(k-1)*(1-2*x1(k-1)*x1(k-1)-0.5*x1(k-1)*x1(k-1)*x1(k-1)*x1(k-1)) - x1(k-1))*h;
t=t+h;
end
plot(x2,x1,'r');
plot(x2(length(n)),x1(length(n)),'go');
hold on;
%x1(1)=2; x2(1)=-1;
%plot(x2(1),x1(1),'ob');
%hold on
%for k=2:length(n)
%для 1 ур:
%x1(k)=x1(k-1)+x2(k-1)*h;
%для 2 ур:
%x2(k)=x2(k-1)+(M*x2(k-1)*(1-2*x1(k-1)*x1(k-1)-0.5*x1(k-1)*x1(k-1)*x1(k-1)*x1(k-1)) - x1(k-1))*h;
%end
% plot(x2,x1,'b');
% plot(x2(length(n)),x1(length(n)),'yo');
%end