%Wireless sensors for continuous, multimodal measurements at the skin interface with lower limb prostheses %MATLAB code to identify the cycle. %Jean Kwak, Mengdi Han %2020 clear;clc; close all %% set threshold threshold = 50; min_peak_height = 200; min_peak_distance = 0.3; %% import data figure(1); fid = fopen('data.txt'); data = textscan(fid, '%f %f'); fclose(fid); pressure = data{2}; pressure = pressure(~isnan(pressure)); time = data{1}; time = time(~isnan(pressure)); time = time-time(1); plot(time,pressure); title('raw data'); %% find voltage drops figure(2); [pks1,locs1] = findpeaks(-pressure,time,'ThresHold',threshold); hold on plot(time,pressure); scatter(locs1,-pks1); title('find voltage drops'); %% define cycle figure(3); [pks2,locs2] = findpeaks(pressure,time,'MinPeakHeight',min_peak_height,'MinPeakDistance',min_peak_distance); hold on plot(time,pressure); scatter(locs1,-pks1); scatter(locs2,pks2); title('define cycle');