Skip to content

Commit

Permalink
- Added data split for additional fields in struct other than x and y
Browse files Browse the repository at this point in the history
	modified:   startMaster.m
	modified:   startSlave.m
  • Loading branch information
okbalefthanded committed Jul 31, 2018
1 parent 40a9b1d commit 17c0012
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
16 changes: 14 additions & 2 deletions startMaster.m
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,20 @@

function d = getSplit(d, id)
if(isstruct(d))
d.x = d.x(id, :);
d.y = d.y(id, :);
fields = fieldnames(d);
if(numel(fields)==2)
d.x = d.x(id, :);
d.y = d.y(id, :);
else
for fd = 1:length(fields)
if(ndims(d.(fields{fd}))==3)
d.(fields{fd}) = d.(fields{fd})(:,:, id);
else if(ismatrix(d.(fields{fd})) && length(d.(fields{fd}))>sum(id))
d.(fields{fd}) = d.(fields{fd})(id);
end
end
end
end
else
d{1} = d{1}(id, :);
d{2} = d{2}(id, :);
Expand Down
16 changes: 14 additions & 2 deletions startSlave.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,20 @@

function d = getSplit(d, id)
if(isstruct(d))
d.x = d.x(id, :);
d.y = d.y(id, :);
fields = fieldnames(d);
if(numel(fields)==2)
d.x = d.x(id, :);
d.y = d.y(id, :);
else
for fd = 1:length(fields)
if(ndims(d.(fields{fd}))==3)
d.(fields{fd}) = d.(fields{fd})(:,:, id);
else if(ismatrix(d.(fields{fd})) && length(d.(fields{fd})) > sum(id) )
d.(fields{fd}) = d.(fields{fd})(id);
end
end
end
end
else
d{1} = d{1}(id, :);
d{2} = d{2}(id, :);
Expand Down

0 comments on commit 17c0012

Please sign in to comment.