savedata.m 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. clc
  2. close all;
  3. clear all;
  4. x=0;
  5. dt = 1;
  6. t=[0];
  7. % m=[0;0;0;0]
  8. dis_m=[0;0;0;0;0;0;]
  9. p = plot(t,dis_m)
  10. %legend('璘신폭箕','塘신폭箕','r2','r3','b0','b1','b2','b3')
  11. legend('품신','빈신')
  12. grid on;
  13. set(gcf,'unit','normalized','position',[0.2,0.2,0.64,0.7]);
  14. load('瓜拮-P20210823.mat');
  15. clc
  16. buff_len = length(m(1,:));
  17. %炬랬긴좆
  18. F_val_now = 0;
  19. B_val_now = 0;
  20. F_rise_start = 0;
  21. F_val_old = 0;
  22. F_flag_step = 0;
  23. F_filter_val = 0;
  24. F_filter_val_now = 0;
  25. B_filter_val_now = 0;
  26. F_step_time_1 = 0;
  27. F_step_time_2 = 0;
  28. F_step_time_min = 0;
  29. F_step_time_max = 0;
  30. F_step_time_cnt = 0;
  31. F_step_zero = 0;
  32. for k = 1:buff_len
  33. F_val_now = m(1,k);
  34. B_val_now = m(2,k);
  35. if F_flag_step>0
  36. F_flag_step = 0;
  37. end
  38. F_val_sum = F_val_now + B_val_now;
  39. %炬랬
  40. % F_filter_val = bitshift((bitshift(uint32(F_filter_val),3)-F_filter_val+F_val_sum),-3);
  41. % F_filter_val = (F_filter_val*3-F_filter_val+F_val_now)/3;
  42. % disp(F_val_now);
  43. % disp(F_filter_val);
  44. % if abs(F_filter_val-F_val_sum)>200
  45. % F_filter_val = F_val_sum;
  46. % end
  47. if F_val_sum>1900
  48. F_step_zero = 3000
  49. else
  50. F_step_zero = 1500
  51. end
  52. % F_step_time_cnt = F_step_time_cnt + 1;
  53. % if F_filter_val>=F_val_old
  54. % if F_rise_start==0
  55. % F_rise_start = F_val_old;
  56. % end
  57. % else
  58. % if F_rise_start>0
  59. % if F_val_old-F_rise_start>800
  60. % F_flag_step = 1000;
  61. % F_step_time_1 = F_step_time_2;
  62. % F_step_time_2 = F_step_time_cnt;
  63. % F_step_time_cnt = 0;
  64. % elseif F_val_old-F_rise_start>500
  65. % tempV = [F_step_time_1,F_step_time_2];
  66. % F_step_time_min = min(tempV);
  67. % F_step_time_max = max(tempV);
  68. % if F_step_time_max-F_step_time_min<3 && abs((F_step_time_max+F_step_time_min)/2-F_step_time_cnt)<5
  69. % F_flag_step = 500;
  70. % else
  71. % F_flag_step = 100;
  72. % end
  73. % F_step_time_1 = F_step_time_2;
  74. % F_step_time_2 = F_step_time_cnt;
  75. % F_step_time_cnt = 0;
  76. % end
  77. % F_rise_start = 0;
  78. % end
  79. % end
  80. % F_val_old = F_filter_val;
  81. dt = dt + 1;
  82. t=[t dt];
  83. if dt>280
  84. x=x+1;
  85. end
  86. dis_m=[dis_m [ F_val_now;B_val_now; F_val_sum;F_step_zero; F_val_sum; F_filter_val]];
  87. set(p(1),'XData',t,'YData',dis_m(1,:))
  88. set(p(2),'XData',t,'YData',dis_m(2,:))
  89. set(p(3),'XData',t,'YData',dis_m(3,:))
  90. set(p(4),'XData',t,'YData',dis_m(4,:))
  91. % set(p(5),'XData',t,'YData',dis_m(5,:))
  92. % set(p(6),'XData',t,'YData',dis_m(6,:))
  93. drawnow limitrate nocallbacks
  94. axis([x x+300 -100 5000]);
  95. % pause(0.001);
  96. end