-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalA2.m
executable file
·33 lines (32 loc) · 883 Bytes
/
calA2.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function [A2,f1]=calA2(dirnamef)
disp(dirnamef);
cd(dirnamef)
f1=str2double(dirnamef);
period=1/str2double(dirnamef); %
%%
%if f1(i)~=1.4; cd ../; continue;end
%%
[t,y]=textscanty;
if length(t)<2; A2=NaN; return; end
dt=t(3)-t(2);
period1n=ceil(period/dt);
period1n=period1n*1;% number of periods per period
Lt=length(t);
nperiod=floor(Lt/(period1n));
%%
if nperiod<10; A2=NaN; return; end%
%if nperiod<30; continue; end
%%
disp(pwd)
disp([num2str(nperiod),'periods'])
ystart=floor(Lt/3*2); %It takes the last 2/3 values
if ystart>Lt;A2=NaN; return; end
if (Lt-ystart)<period1n*3; ystart=(Lt-period1n*3);end% get at least 3 periods
A2=0.5*(max(y(ystart:Lt))-min(y(ystart:Lt)));%(max in 70 period - min)/2
%based on assumption fo f1=f2
%and vibration becomes
%steady after a few periods
%else
%A2(i)=mean(yampds(yampn:2*yampn));
%end
%A2(i)=yampds(1);