## Replace a multiple of two symbolic numbers

on 18 Oct 2012

### Star Strider (view profile)

Hi,
I'm attempting to replace (to linearise my equation) the multiple of two very small values dx and dy.
I attempted to use subs but it doesn't seem to work.
Code: PO=subs(PO,[(dx*dy),(dy*dx)],[0,0]);
PO is my symbolic vector. There is no error message but it just doesn't pick up the combination. Any Ideas?
Thanks!
Matlab Version: 2012a

### Star Strider (view profile)

on 18 Oct 2012
Edited by Star Strider

### Star Strider (view profile)

on 18 Oct 2012

I honestly don't understand why your subs call doesn't work. I can't make it work either, in spite of a number of different approaches that have worked for me previously. I consider this a bug, so you may want to report it to TMW as such.
All is not lost, however. Here's a kludgy but effective work-around. Note that it still only recognizes (dx*dy) and not such as (dx*dy)^2:
syms dx dy x y
PO = expand( (x + dx) * (y + dy) + (dx * dy) ) % Prototype expression
[POc, T] = coeffs(PO, [dx dy])
Tfind = find(T == 'dx*dy')
POc(Tfind) = 0
PO = POc * T.'
This could probably be made more efficient. I wrote it as I did to make the logic behind it transparent.

Moritz

### Moritz (view profile)

on 19 Oct 2012
Thanks! I adapted it to make it work with vectors and now it works like a charm.
Thank you very much!
P.S.: I'm gonna report it as a bug and see what Mathworks has to say about it.
Star Strider

### Star Strider (view profile)

on 19 Oct 2012
Great! I'm glad it worked for you. It is always my pleasure to help.
Please post what TMW replies to your bug report here in a new ‘Answers’ question (use ‘announcement’ as the first tag and then the same tags and products you used here), and include a link to this thread so you don't have to completely re-describe the problem. This seems to me to be a significant issue — and one I hadn't previously discovered — so it merits special attention.