Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % i
- clc;
- clear;
- syms x z;
- tspan = [0,10]; % Visualise solution from 0 to 5 seconds
- x0 = [1,1]; % Initial condition of 1
- L = 3;
- kappa = 2;
- rho = L + kappa/sqrt(2);
- sigma(x,z) = x^2 + 4*x - 0.5*z;
- v(x,z) = -rho*sign(sigma(x,z));
- u(x,z) = v(x,z) - 2*x^3 - 10*x^2 - 12*x + x*z + 2*z;
- u_func = matlabFunction(u(x,z));
- [t,x] = ode45(@(t,x) f_1(x,t,u_func),tspan,x0); % Solve for x in the un-perturbed system
- x_surface = linspace(0,2,10);
- z_surface = 2*x_surface^2 + 8*x_surface;
- % Visualise solutions
- figure('Name','i_1','NumberTitle','off','Position', [100, 100, 700, 400]);
- subplot(1,2,1);
- plot(x(:,1),x(:,2),'Linewidth',2);
- title('x(t), z(t)');
- xlabel('x(t)');
- ylabel('z(t)');
- subplot(1,2,2);
- plot(x_surface,z_surface,'Linewidth',2);
- title('Sliding surface sigma = 0');
- xlabel('x(t)');
- ylabel('z(t)');
- %
- figure('Name','i_2','NumberTitle','off','Position', [100, 100, 700, 400]);
- subplot(1,3,1);
- plot(t,x(:,1),'Linewidth',2);
- title('t, x(t)');
- xlabel('Time (s)');
- ylabel('x(t)');
- xlim(tspan);
- subplot(1,3,2);
- plot(t,x(:,2),'Linewidth',2);
- title('t, x(t)');
- xlabel('Time (s)');
- ylabel('x(t)');
- xlim(tspan);
- subplot(1,3,3);
- plot(t,sigma(x(:,1),x(:,2)),'Linewidth',2);
- title('t, x(t)');
- xlabel('Time (s)');
- ylabel('x(t)');
- xlim(tspan);
- %%
- function dX = f_1(x,t,u_func)
- u = u_func(x(1),x(2));
- dx = x(1)^2 + 3*x(1) - 0.5*x(2);
- dz = -2*u + cos(t) + 2*sin(3*x(1)*x(2));
- dX = [dx;dz];
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement