I ran the following code on 2024a
m1c(x) = c2 + c1*x + heaviside(x - 4)*(3*x - 2)*(x - 4);
This line causes an error on 2024b and can't run here
s = simplify(diff(m1c(x),x),'All',true)
end
ans = 'Invalid number of arguments.'
so I've uploaded the 2024a result.
At first glance, the result seems pretty reasonable
s
s =

but those first two elements do look a bit odd.
As expected, s is a sym and is a 3 x 1 vector
size(s)
ans =
3 1
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
But closer inspection of s reveals that its first two elements are themselves 1 x 2 vectors and the third is a scalar (which would show clearly in the command window, but since Answers uses LiveScript I use char here)
It looks like the first and second elements of the first element of s are the subexpression and expression respectively. Same for the second element of s.
We can verify the dimensions of each element
arrayfun(@(s) size(s),s,'uni',false)
ans =
{[1 2]}
{[1 2]}
{[1 1]}
So sym arrays seem more like cell arrays from this perspective, even though sym arrays use paren indexing and not curly brace indexing.
An element can be extracted from s
s1 = s(1)
s1 = 
and we can index into that
s1(1)
ans = 
and operate on the result
s1(2)*2
ans = 
But we can't perform a basic operation on s1 itself
s1*2
Error using * (line 362)
Invalid return value '[2*c1 - 28*heaviside(x - 4) + 12*x*heaviside(x - 4), 2*c1 - 28*heaviside(x - ...'. It must be of type 'Type::MATLABOutput'.
Any idea what's going on here?
Also, any idea why @doc:simplify returns s in this form from the outset? I saw nothing on the doc page that indicated that this behavior is expected.