Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function[n] = Lab5_1( f,X0,A,n0,e )
- % f - функция с символьными х,у
- % Х0 - координаты начальной точки
- % А - отрезок [a,b]
- % n0 - начальное число отрезкой разбиения
- % е - точность
- % Starting Point
- x0=X0(1);
- y0=X0(2);
- % Interval
- a=A(1);
- b=A(2);
- dx=(b-a)/n0;
- % X and Y arrays for plot
- X(1)=x0;
- Y(1)=y0;
- % X1 and Y1 arrays for n*2 plot
- X1(1) = x0;
- Y1(1) = y0;
- for i=1:1:n0
- syms x y;
- if (Y(i) + subs(f,{'x','y'},[X(i) Y(i)])*dx == inf)
- break
- else
- Y(i+1) = Y(i) + subs(f,{'x','y'},[X(i) Y(i)])*dx;
- end
- X(i+1) = X(i) + dx;
- end
- plot(X, Y, 'r')
- dx = dx/2;
- n = n0*2;
- for i=1:1:2*n0
- if (Y1(i) + subs(f,{'x','y'},[X1(i) Y1(i)])*dx == inf)
- break
- else
- Y1(i+1) = Y1(i) + subs(f,{'x','y'},[X1(i) Y1(i)])*dx;
- end
- X1(i+1) = X1(i) + dx;
- plot(X1,Y1,'g');
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement