Returns for loop data within parfor loop to a structure.
[structed] = parstruct(structed,nvars,varname,n,varargin)
Input variables
structed: name of the structure
nvars: number of input variables
varname: fieldnames of the structure
n: for loop index (use n = 1 to save noniterative data or to define fieldname for the first time and save data. n must be an positive integer)
varargin: data to be structed, Variable-length input argument
Output variable
structed: structed data of each parfor loop
Caution
nvars and the size of varargin, and varname must be the same
n IS NOT the index of parfor loop
must define fieldname before save date (read description of input variable n)
How to use & Example
parfor loop condition: initVal = 1, endVal = 3
for loop condition: n_end = 5
the result struct is
Field1 and Field2 is iterative data of 17 * 17 matrix with 5 for loop iterations. hence it becomes 17 * 17 * 5 matrix
Noniter1 and Noniter2 is noniterative data