function plot_data(data_name) load(data_name); clc press_1 = m(1,:); press_2 = m(2,:); press_max = 0; press_min = 0; state =0; bushu =0; buff_len = length(press_1(:)); mdflag =(1:buff_len); mdmin_buff =(1:buff_len); mdmax_buff =(1:buff_len); lvbo=(1:5); for k = 1:buff_len % disPress(1) = press_1(k); % disPress(2) = PressBasic; % disPress(3) = press_min; % disPress(4) = press_max; % disp(disPress); for i=1:4 lvbo(i) = lvbo(i+1); end lvbo(5) = press_1(k); avage = (lvbo(2)+lvbo(3)+lvbo(4))/3; if avage >= lvbo(1) && avage >= lvbo(5) if press_1(k) ~= 0 if k >= 2 press_min = lvbo(5)+200; press_max = lvbo(5)+700; end end end switch state case 0 mdflag(k) = 0; if press_1(k) > press_max state = 1; bushu = (bushu+1); mdflag(k) = 300; end case 1 mdflag(k) = 0; if press_1(k) < press_min state=0; end end if k >= 2 mdmin_buff(k) = press_min; mdmax_buff(k) = press_max; end end figure; plot(press_1); hold on; plot(mdflag); hold on; plot(mdmin_buff); hold on; plot(mdmax_buff); hold on; disp(['计算的步数:',num2str(bushu)]); legend('前脚','后脚') end