Sorry...... I shouldn't made it in such
a complex way......
Simple definition is enough.
Excuse me......
Renpoo
On 12/27/14 12:34, TAISO, Renpoo wrote:
Hi there.
I have a question on using Struct in octave.
Would you look at these codes?
I wanna AUTOMATICALLY set up the Struct containing both integers
and NULL ARRAYs for the returning values for a function, to define
each variables from the Struct.
results = struct( ...
'resultData', {}, ... % result 1
'timeAxis', {}, ... % result 2
'maxValues', {}, ... % result 3
'maxIdxs', {}, ... % result 4
'maxTimes', {}, ... % result 5
'zeroIdxs', {}, ... % result 6
'ICCC', 0, ... % result 7
'tauICCC', 0, ... % result 8
'Wiccc', 0, ... % result 9
'PHI_ll_0', 0, ... % result 10
'PHI_rr_0', 0, ... % result 11
'PHI_lr', {}, ... % result 12
'phi_lr', {}); % result 13
results_fields = fieldnames(results);
nargin = 13;
for i = 1:nargin,
if ( isnumeric( getfield( results,
results_fields{i}, {2} ) ) ),
results.( results_fields{i} ) = eval( num2str( results.(
results_fields{i} ) ) );
else,
results.( results_fields{i} ) =
eval( results.( results_fields{i} ) );
endif;
endfor;
1st. problem is "isnumeric( getfield(
results, results_fields{i}, {2} ) ) ".
I wanna identify whether or not it is numeric for the value field
of the Struct "results".
2nd. problem is "eval( results.(
results_fields{i} ) );" in case that I wanna assign
NULL ARRAY inside of the Struct "results".
What should I do to refactor these codes?
Thanks in advance.
Renpoo
|