|
pouncingmoose@gmail.com wrote:
> I'm using R2008b on win32.
> %%%%%%%%% Cut Here %%%%%%%%%%%%%
> function [out1,out2,out3,out4] = LoadCustomData
> out1 = 1; out2 = 2; out3 = 3; out4 = 4;
> %%%%%%%%% Cut Here %%%%%%%%%%%%%
> % This does not work
> clear all
> [ad.field1{1}.outD,ad.field2.outA,ad.field2.outB,ad.field2.outC] =
> LoadCustomData;
> ??? Illegal right hand side in assignment. Too many elements.
I confirm that the same thing happens on R2008b on Linux-64.
It does not, however, happen on R2007a on Linux-64.
The work-around that I found makes no sense, but it works:
[ad.field1{1}.outD,ad.field2.outA(1),ad.field2.outB,ad.field2.outC] = LoadCustomData;
That is, adding the (1) after the outA allows the assignment to go smoothly.
Alternately,
[ad.field1{1}.outD,ad.field2(1).outA,ad.field2.outB,ad.field2.outC] = LoadCustomData;
The problem is not so easy to trigger. What I have found is:
There must be at least 4 possible output arguments to trigger the condition;
Let C stand for a cell reference, and S2 stand for a direct two-level structure
reference without any modification (e.g., X.Y.Z), and A stand for any output
argument. Then it appears that to trigger the condition, at some point in the
output arguments, there must either be C, S2, S2, A or S2, C, S2, A
S2, S2, C, A does not trigger the problem. The repetition of S2 is not intended here
to indicate that the references must duplicate each other: they can be completely
different as long as they are two-level structure references:
For example,
[P{1}, X.Y.Z, S.T.U, B] = LoadCustomData; %FAIL, 4 output arguments
[X.Y.Z, P{1}, S.T.U, B] = LoadCustomData; %FAIL, 4 output arguments
[X.Y.Z, S.T.U, P{1}, B] = LoadCustomData; %PASS, 4 output arguments
If there are enough possible output arguments, this pattern may be proceeded by
arbitrary output arguments, such as
[R, P{1}, X.Y.Z, S.T.U, B] = LoadCustomData5; %FAIL, 5 output arguments
[P{1}, X.Y.Z, S.T.U, B] = LoadCustomData6; %FAIL, 6 output arguments
[R, P{1}, X.Y.Z, S.T.U, B] = LoadCustomData6; %FAIL, 6 output arguments
However, if the function allows more possible output arguments after the
start of the described pattern, and any of those output arguments is provided,
then the problem will -not- occur:
[P{1}, X.Y.Z, S.T.U, B, R] = LoadCustomData5; %PASS, 5 output arguments
[R, P{1}, X.Y.Z, S.T.U, B, F] = LoadCustomData6; %PASS, 6 output arguments
This might not be a complete characterization of the problem, but it's enough
that I will submit a bug report.
|