1

How do I access data field in spmd block?

I have the following code --

function output = spmd_fieldname_test(input)
spmd
input = distributed(input);
allFieldnames = fieldnames(input);
    for ithField = 1:numel(allFieldnames)
        output = vertcat(input.(allFieldnames{ithField}));
    end
end %spmd
end %function

However, I've got the following error -
Error using codistributed/subsref (line 27)
Distributed SUBSPEF currently only supports () indexing.

So, does this mean that I have to do struct2cell and perform my own fieldname index keeping in this case?

Maroon66
  • 41
  • 3
  • Assuming it's the line in your `for` loop throwing the error (it's always useful if you post the full error and stack trace when available), it means dynamic field referencing isn't supported for `distributed` arrays. I don't have this toolbox so I can't verify or see what you can do other than addressing the fields explicitly. – sco1 Oct 27 '15 at 14:24
  • stacktrace doesn't do much except saying -- Error in function spmd_fieldname_test (line xx) spmd. Also, what do you mean by addressing the fields explicitly? – Maroon66 Oct 27 '15 at 14:34

0 Answers0