22 lines
724 B
Matlab
22 lines
724 B
Matlab
function [ppstruct] = convert_particles_cell2struct(pp,col)
|
|
% [ppstruct] = convert_particles_cell2struct(pp,col)
|
|
% Converts MATLAB particle data from 'cell' format to 'struct'
|
|
% Input
|
|
% pp particle data in 'cell' format
|
|
% col column map
|
|
% Output
|
|
% ppstruct particle data in 'struct' format
|
|
|
|
% Convert map to (cell) arrays and sort by ascending array indices
|
|
[colvals,idx] = sort(cell2mat(col.values));
|
|
colkeys = col.keys;
|
|
colkeys = {colkeys{idx}};
|
|
nkeys = col.Count;
|
|
|
|
nstep = numel(pp);
|
|
for istep=nstep:-1:1
|
|
for ikey=1:nkeys
|
|
ppstruct(istep).(colkeys{ikey}) = pp{istep}(colvals(ikey),:);
|
|
end
|
|
end
|
|
end |