Advertisement
cyphric

Untitled

Sep 25th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.68 KB | None | 0 0
  1. %Uppgift 5, som 4 fast med modifikation
  2. %Fall 1: aR = aL = 3, wR = 1, wL = 5
  3. clc; clear all; close all;
  4. aR = [3 4 1 1.2];
  5. aL = [3 2 3 0.4];
  6. wR = [1 3 6 3];
  7. b = 1;
  8. wL = [5 2 1 1];
  9. x0 = 0;
  10. y0 = 1.5;
  11. theta0 = 0;
  12. s0 = [x0 y0 theta0];
  13. options = odeset('RelTol',1e-6,'Abstol',1e-6, 'refine', 4);
  14. tspan = [0 10]';
  15.  
  16. for i = 1:4
  17.    
  18.     [t,s] = ode45(@(t,s) fvel(t,s,b,aL(i),aR(i),wL(i),wR(i)),[0 10],s0,options);
  19.     figure(i)
  20.     plot3(s(:,1),s(:,2),t); grid on; %figure 4 är uppgift 6 b
  21.  
  22. end
  23.  
  24.  
  25.  
  26. function ds = fvel(t,s,b,aL,aR,wL,wR)
  27. vR = aR*t + wR;
  28. vL = aL*t + wL;
  29. v = (vR + vL)/2;
  30. dtheta = (vR - vL)/b;
  31. theta = s(3);
  32. ds = [v*cos(theta), v*sin(theta), dtheta]';
  33.  
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement