plot_data.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. function plot_data(data_name)
  2. load(data_name);
  3. clc
  4. press_1 = m(1,:);
  5. press_2 = m(2,:);
  6. press_max = 0;
  7. press_min = 0;
  8. state =0;
  9. bushu =0;
  10. buff_len = length(press_1(:));
  11. mdflag =(1:buff_len);
  12. mdmin_buff =(1:buff_len);
  13. mdmax_buff =(1:buff_len);
  14. lvbo=(1:5);
  15. for k = 1:buff_len
  16. % disPress(1) = press_1(k);
  17. % disPress(2) = PressBasic;
  18. % disPress(3) = press_min;
  19. % disPress(4) = press_max;
  20. % disp(disPress);
  21. for i=1:4
  22. lvbo(i) = lvbo(i+1);
  23. end
  24. lvbo(5) = press_1(k);
  25. avage = (lvbo(2)+lvbo(3)+lvbo(4))/3;
  26. if avage >= lvbo(1) && avage >= lvbo(5)
  27. if press_1(k) ~= 0
  28. if k >= 2
  29. press_min = lvbo(5)+200;
  30. press_max = lvbo(5)+700;
  31. end
  32. end
  33. end
  34. switch state
  35. case 0
  36. mdflag(k) = 0;
  37. if press_1(k) > press_max
  38. state = 1;
  39. bushu = (bushu+1);
  40. mdflag(k) = 300;
  41. end
  42. case 1
  43. mdflag(k) = 0;
  44. if press_1(k) < press_min
  45. state=0;
  46. end
  47. end
  48. if k >= 2
  49. mdmin_buff(k) = press_min;
  50. mdmax_buff(k) = press_max;
  51. end
  52. end
  53. figure;
  54. plot(press_1);
  55. hold on;
  56. plot(mdflag);
  57. hold on;
  58. plot(mdmin_buff);
  59. hold on;
  60. plot(mdmax_buff);
  61. hold on;
  62. disp(['¼ÆËãµÄ²½Êý:',num2str(bushu)]);
  63. legend('Ç°½Å','ºó½Å')
  64. end