cycle to cyle period of a signal--matlab
input:
time series of displacement
output
code
% key function: findpeaks clear; clc; %% read data %data=xlsread('nogapur5.xlsx'); data=importdata('data.txt'); t=data(1:2000,1); % time, 3s dis=data(1:2000,2); % dis dis_nor=dis./0.1; % dis nor lift=data(1:2000,3); % lift drag=data(1:2000,4); % drag %%%%%%%%%%%%%%%%%%%% fig. 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% figure(1); plot(t,dis_nor,'k-'); xlabel('\it t(s)','fontsize',10,'fontname','Times New Roman'); ylabel('\it Dis./fn','fontsize',10,'fontname','Times New Roman'); [pks,locs]=findpeaks(dis,t); % peaks and locations % plot the peaks using findpeaks and label them findpeaks(dis,t); text(locs+.02,pks,num2str((1:numel(pks))')); saveas(gcf,'peaks','jpg'); T=diff(locs); f=1./T; fn=1.46; f_nor=f./fn; time=locs(2:end); %%%%%%%%%%%%%%%%%%%% fig. 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% figure(2); plot(time,f_nor,'k:o'); xlabel('\it t(s)','fontsize',10,'fontname','Times New Roman'); ylabel('\it f_{osc}/fn','fontsize',10,'fontname','Times New Roman'); %% figure size % fig = gcf ; % fig.PaperUnits = 'inches'; % fig.PaperPosition = [0 0 4 3]; saveas(gcf,'f_osc_vs_time','jpg');