-
Notifications
You must be signed in to change notification settings - Fork 2
/
fftoptions.m
114 lines (91 loc) · 3.16 KB
/
fftoptions.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
%*-------------------------------------------*
%| FFT Calculation options GUI function |
%| (Rowland Sillito September 2001) |
%|-------------------------------------------|
%| created as an accessory |
%| for use with Computefft function & Spikes |
%*-------------------------------------------*
function [options]=fftoptions(tf)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%------------------ Variable Declaration ------------------%
%declare variables
persistent harmn1
persistent harmn2
persistent infpoint
persistent zeropoint
persistent acceptable
global choice
%--------------- End of Variable Declaration ---------------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%----------------------- Main Program ----------------------%
%%initialisation
%loads GUI
fftoptionbox;
figpos(1);
set(ghft('TempFreqBox'),'String',num2str(tf));
%choice is only set to 1 when user clicks on one of the buttons
choice=0;
acceptable=0;
%sets callbacks for exit and continue buttons
set(ghft('FFTContinueButton'),'Callback','global choice; choice=1;');
while acceptable==0 %acceptable values in the box???
%%waits until the user has clicked on continue
tf = str2num(get(ghft('TempFreqBox'),'String'));
while choice==0
pause(0.25);
end
if get(ghft('SingleHarmonic'),'Value')==1
v=str2num(get(ghft('SingHarmnBox'),'String'));
tf = str2num(get(ghft('TempFreqBox'),'String'));
if (~isempty(v) && v>=0)
harmn1=v;
harmn2=inf;
infpoint=inf;
zeropoint=0;
acceptable=1;
else
Errordlg('Harmonic must be >=0','Incorrect values entered!');
choice=0;
end
else
v=str2num(get(ghft('Harmn1Box'),'String'));
w=str2num(get(ghft('Harmn2Box'),'String'));
inp=str2num(get(ghft('InfPointBox'),'String'));
zep=str2num(get(ghft('ZeroPointBox'),'String'));
tf = str2num(get(ghft('TempFreqBox'),'String'));
if (~isempty(v) & v>=0) & (~isempty(w) & w>=0) & (v~=w)
harmn1=v;
harmn2=w;
acceptable=1;
if get(ghft('SetInfPoint'),'Value')==1 & ~isempty(inp) & ~isempty(zep)
infpoint=inp;
zeropoint=zep;
else
infpoint=inf;
zeropoint=0;
end
else
warndlg('Harmonics must be >=0, and where 2 are specified for calculating a ratio, they must be different.','Incorrect values entered!');
choice=0;
end
end
end
options=[harmn1,harmn2,infpoint,zeropoint,tf];
close(gcf);
%-------------------- End of Main Switch -------------------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%------------ Extra Function Declarations ------------------%
%GHFT GetsHandleFromTag
function [handle] = ghft(tag)
handle=findobj('tag',tag);
%End of handle getting routine%
%Converts array of numbers to a cell array of strings
function [cellout]=nums2strs(arrayin)
for n=1:length(arrayin)
cellout{n}=num2str(arrayin(n));
end
%End of function
%------------------- End of Declarations -------------------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%