From: David on
Hi,

I'm writing a bunch of functions which will require various levels of differentiation. One problem I've run into straightaway is that the output from the symbolic diff does not respect the element-wise operators in the input. For example:

>> diff(x.^2)

ans =

2*x

I now want to use 2*x to define a new function, but I need 2.*x as ultimately I want to be passing in vectors . Shouldn't the answer should be 2.*x to be consistent with the input? Is there a neat way around this? I can only think of converting the output to a character array and making a conversion * -> .*, / -> ./ etc but that's a little clunky!

Thanks,
David.