-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanual_init_running.m
More file actions
64 lines (59 loc) · 2.92 KB
/
manual_init_running.m
File metadata and controls
64 lines (59 loc) · 2.92 KB
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Center for Astronomy Signal Processing and Electronics Research %
% http://casper.berkeley.edu %
% Copyright (C) 2011 Hong Chen %
% %
% This program is free software; you can redistribute it and/or modify %
% it under the terms of the GNU General Public License as published by %
% the Free Software Foundation; either version 2 of the License, or %
% (at your option) any later version. %
% %
% This program is distributed in the hope that it will be useful, %
% but WITHOUT ANY WARRANTY; without even the implied warranty of %
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the %
% GNU General Public License for more details. %
% %
% You should have received a copy of the GNU General Public License along %
% with this program; if not, write to the Free Software Foundation, Inc., %
% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [param,values] = manual_init_running(blk,init_script_name,setting)
%% running init script for current block
%%% Inputs:
% blk = the block to renew
% init_script_name, type: string the name of the init file
% settings = {'vername',value, ...} pairs
%%% Outputs:
% param = {'vername,value,...} pairs with all the user data
% values = {value, ...} retrieves all the values from the param
%%%%% to find out the parameter names, run it with setting={}
%%%%% to reset some of the parameters, run it as
%%%%% settings={'vername1',value1, 'vername2',value2, ...};
% example: [params,values]=manual_init_running(gcb, 'fir_col_init', {'n_inputs',2})
% then you can run fir_col_init_xblock(values{:});
%%
dialogparam = getfield(get_param(gcb,'UserData'),'parameters');
try
dialogparam=rmfield(dialogparam,'defaults');
catch
err=1;
end
disp('Use Data:');
names = fieldnames(dialogparam)
size_names=size(names);
num_names=size_names(1);
param=cell(1,2*num_names);
for i=1:num_names,
param{1,2*i-1}=names{i,1};
if (~isnan(get_var(names{i,1},setting{:})))
param{1,2*i}=get_var(names{i,1},setting{:});
else
param{1,2*i}=getfield(dialogparam,names{i,1});
end;
end
param
values=param(2:2:end);
init_func=str2func(init_script_name);
init_func(blk, param{:});