Skip to content

Commit 849b8ba

Browse files
authored
Add files via upload
1 parent fd0eba0 commit 849b8ba

12 files changed

+3953
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function [time_vector] = f_hhmm2timevec(hhmm)
2+
% Convert time representation hhmm to time vector
3+
% E.g.
4+
% If hhmm=[2205 2350 0 103 230] then
5+
% f_hhmm2timevec(hhmm) returns:
6+
% [22 5
7+
% 23 50
8+
% 0 0
9+
% 1 3
10+
% 2 30]
11+
12+
if size(hhmm,1)>1 & size(hhmm,2)>1
13+
disp('Input must be a scalar or vector');
14+
return;
15+
elseif size(hhmm,2)>1
16+
hhmm=hhmm';
17+
end
18+
hh = floor(hhmm/1e2);
19+
mm = hhmm - floor(hhmm/1e2)*1e2;
20+
time_vector=[hh mm];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
function [selectedNum]=f_menu_of_numbers_title(menu_title,v)
2+
% Set Menu of numbers in the vector v with a title 'menu_title';
3+
% USE:
4+
%leg=f_menu_of_numbers_title('Survey#',[1:4]);
5+
%if isempty(leg), return; end
6+
% Olga Kosnyreva, AOPE/WHOI, 5/5/2006
7+
8+
selectedNum=[];
9+
if nargin==1 % number_start can be a vector in this case
10+
disp('Not enought input arguments');
11+
return;
12+
elseif nargin==2 % number_start can be a vector in this case
13+
if ~isstr(menu_title)
14+
disp('First argument must be a string');
15+
return;
16+
end
17+
if ~isnumeric(v)
18+
disp('Second argument must be a scalar or vector of numbers');
19+
return;
20+
end
21+
st=v;
22+
if size(st,1)==1, st=st'; end % vector must be a column
23+
else
24+
disp('Incorrect input');
25+
return;
26+
end
27+
%*******************************************************************************
28+
%*********************************** MENU of ## **************************
29+
%*******************************************************************************
30+
% Convert vector of numbers to vector of strings.
31+
st_str=num2str(st);
32+
% Add one more element to vector of strings ('CANCEL').
33+
st_str=strvcat(st_str,'CANCEL');
34+
% Convert vector of strings to cell array.
35+
st_cell=cellstr(st_str);
36+
% Set Menu.
37+
st_num = menu(menu_title, st_cell);
38+
% If Menu item is 'CANCEL' terminate program.
39+
if (st_num > size(st_cell,1)-1), return; end
40+
% Get Leg number (string).
41+
stNum_str=st_cell{st_num};
42+
% Get Leg number (number).
43+
selectedNum=str2num(stNum_str);
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+
115+
116+
117+
118+
119+
120+
121+
122+
123+
124+
125+
126+
127+
128+
129+
130+
131+
132+
133+
134+
135+
136+
137+
138+
139+
140+
141+
142+
143+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
function [s]=f_menu_of_strings(header,S)
2+
% f_menu_of_strings
3+
% GENERATES menu of choises for user input.
4+
% Displays the HEADER string followed in sequence by
5+
% the menu-item strings which are the rows of a string matrix S
6+
% (as returned by STRVCAT).
7+
% RETURNS a string - menu-item name
8+
9+
s='';
10+
if nargin==1 % number_start can be a vector in this case
11+
disp('Not enought input arguments');
12+
return;
13+
elseif nargin==2 % number_start can be a vector in this case
14+
if ~isstr(header)
15+
disp('First argument must be a string');
16+
return;
17+
end
18+
if ~isstr(S)
19+
disp('Second argument must be a matrix of strings as returned by STRVCAT');
20+
return;
21+
end
22+
%st_str=S;
23+
else
24+
disp('Incorrect input');
25+
return;
26+
end
27+
%*******************************************************************************
28+
%*********************************** MENU of ## **************************
29+
%*******************************************************************************
30+
% Add one more element to vector of strings ('CANCEL').
31+
s_str=strvcat(S,'CANCEL');
32+
% Convert vector of strings to cell array.
33+
s_cell=cellstr(s_str);
34+
% Set Menu.
35+
s_num = menu(header,s_cell);
36+
% If Menu item is 'CANCEL' terminate program.
37+
if (s_num > size(s_cell,1)-1), return; end
38+
% Get string as menu-item choice (string).
39+
s=s_cell{s_num};

0 commit comments

Comments
 (0)