Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1.  
  2. function g = gaussian(x,pos,wid)
  3. % gaussian(x,pos,wid) = gaussian peak centered on pos, half-width=wid
  4. % x may be scalar, vector, or matrix, pos and wid both scalar
  5. % T. C. O'Haver, 1988
  6. % Examples: gaussian([0 1 2],1,2) gives result [0.5000 1.0000 0.5000]
  7. % plot(gaussian([1:100],50,20)) displays gaussian band centered at 50 with width 20.
  8. g = exp(-((x-pos)./(0.60056120439323.*wid)) .^2);
  9. endfunction
  10.  
  11. function R = derivative(X,n,k)
  12.  
  13. l = length(X);
  14. R = [];
  15.  
  16. for i = 1:l-n
  17.  
  18. P = polyfit( linspace(-n/2,n/2,n+1)' , X(i:i+n), n);
  19. R = [ R ; P(k) ];
  20.  
  21. endfor
  22.  
  23. endfunction
  24.  
  25.  
  26. DD=sqrt(sum((B.-C).^2,2));
  27.  
  28. DY=B(:,2)-C(:,2);
  29. DX=B(:,1)-C(:,1);
  30. W=atan2(DY,DX);
  31.  
  32. CA=[];
  33. for i=1:437
  34. alpha=-W(i);
  35. M=[[cos(alpha),-sin(alpha)];[sin(alpha),cos(alpha)]];
  36. CA=[CA;(A(i,:)-B(i,:))*M/DD(i)];
  37. endfor
  38.  
  39. # Plot 1 (Unkorrigierte und korrigierte Geschwindigkeiten)
  40. #
  41. # plot([derivative(-A(:,2),1,1),derivative(-CA(:,2),1,1)*505.57])
  42.  
  43. G1 = gaussian(linspace(-10,10,15),0,8);
  44.  
  45. # Referenzkurve 1: Geradenabschnitt, Parabel, die die Messwerte bei Frame 291 schneidet und den Scheitelpunkt
  46.  
  47. R = [ ones(290,1)*(-0.12418); polyval(polyfit([232;291;350],CA([350;291;350],2),2),291:437)'];
  48.  
  49. # Plot 2 (geglättete Geschwindigkeiten mit Referenzkurve)
  50. #
  51. # plot([derivative(conv(-A(:,2),G1),1,1),derivative(conv(-CA(:,2),G1),1,1)*505.57,derivative(conv(-R1,G1),1,1)*505.57](15:end-15,:))
  52.  
  53. # "Padding" (Erweiterung nach vorn: Konstant, nach hinten: Parabel)
  54.  
  55. D = [ones(200,1)*0.1263;-CA(:,2);polyval(polyfit([350,400,437]',-CA([350,400,437],2),2),437:637)'];
  56.  
  57. # Plot 3 (Beschleunigungen, zwei Glättungsstufen, geglättete Referenzkurve)
  58.  
  59. plot([zeros(68,1);(-derivative(conv(R,G1),2,1)(15:end-15))*0.2],'r',derivative(conv(D,G1),2,1)(136+7:end-137-7)*0.168,'b--',derivative(conv(D,G2),2,1)(136+17:end-137-17)*0.08,'b')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement