SHARE
TWEET

Untitled

a guest Sep 18th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. % i
  2. clc;
  3. clear;
  4. syms x z;
  5. tspan = [0,10];      % Visualise solution from 0 to 5 seconds
  6. x0 = [1,1];             % Initial condition of 1
  7.  
  8. L = 3;
  9. kappa = 2;
  10. rho = L + kappa/sqrt(2);
  11. sigma(x,z) = x^2 + 4*x - 0.5*z;
  12. v(x,z) = -rho*sign(sigma(x,z));
  13. u(x,z) = v(x,z) - 2*x^3 - 10*x^2 - 12*x + x*z + 2*z;
  14. u_func = matlabFunction(u(x,z));
  15. [t,x] = ode45(@(t,x) f_1(x,t,u_func),tspan,x0);    % Solve for x in the un-perturbed system
  16.  
  17. x_surface = linspace(0,2,10);
  18. z_surface = 2*x_surface^2 + 8*x_surface;
  19.  
  20. % Visualise solutions
  21. figure('Name','i_1','NumberTitle','off','Position', [100, 100, 700, 400]);
  22. subplot(1,2,1);
  23. plot(x(:,1),x(:,2),'Linewidth',2);
  24. title('x(t), z(t)');
  25. xlabel('x(t)');
  26. ylabel('z(t)');
  27.  
  28. subplot(1,2,2);
  29. plot(x_surface,z_surface,'Linewidth',2);
  30. title('Sliding surface sigma = 0');
  31. xlabel('x(t)');
  32. ylabel('z(t)');
  33. %
  34.  
  35. figure('Name','i_2','NumberTitle','off','Position', [100, 100, 700, 400]);
  36. subplot(1,3,1);
  37. plot(t,x(:,1),'Linewidth',2);
  38. title('t, x(t)');
  39. xlabel('Time (s)');
  40. ylabel('x(t)');
  41. xlim(tspan);
  42.  
  43. subplot(1,3,2);
  44. plot(t,x(:,2),'Linewidth',2);
  45. title('t, x(t)');
  46. xlabel('Time (s)');
  47. ylabel('x(t)');
  48. xlim(tspan);
  49.  
  50. subplot(1,3,3);
  51. plot(t,sigma(x(:,1),x(:,2)),'Linewidth',2);
  52. title('t, x(t)');
  53. xlabel('Time (s)');
  54. ylabel('x(t)');
  55. xlim(tspan);
  56.  
  57. %%
  58. function dX = f_1(x,t,u_func)
  59. u = u_func(x(1),x(2));
  60. dx = x(1)^2 + 3*x(1) - 0.5*x(2);
  61. dz = -2*u + cos(t) + 2*sin(3*x(1)*x(2));
  62. dX = [dx;dz];
  63. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top