I was debugging what I'm pretty sure is a bug (or at least an inconsistency) in @doc:subs and came across a behavior that I don't understand. I see a different result in the debugger than in the command window for what looks like the exact same sequence of commands. Everything below is copy/paste from the Matlab window w/ annotations added here. If it matters, the sequence in the debugger was executed while in ...\symbolic\@sym\subs.m
First, in the debugger:
Get roots of polynomial
Concatenate into a row
Check the class and size of X
Convert to sym
Check which constructor is called.
C:\Program Files\MATLAB\R2024a\toolbox\symbolic\symbolic\@sym\sym.m
Check class and size of foo.
K>> {class(foo),size(foo)}
Apparently foo is (an ordinary?) 1x2 sym (I went back afterwards and verified that numel(foo) == 2).
So why does foo(1) return the entire array?
[(3^(1/2)*1i)/2 - 1/2, - (3^(1/2)*1i)/2 - 1/2]
And foo(2) results in error?
Index exceeds the number of array elements. Index must not exceed 1.
Quit debugger
Repeat sequence in command window
C:\Program Files\MATLAB\R2024a\toolbox\symbolic\symbolic\@sym\sym.m
Note that exact same constructor is called as above from the debugger.
>> {class(foo),size(foo)}
Here we get the expected indexing behavior.
What's different between command window and debugger?
Can anyone replicate (or not) this behavior in a more recent release than 2024a?