Replace a multiple of two symbolic numbers
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuesta aceptada
Star Strider
el 18 de Oct. de 2012
Editada: Star Strider
el 18 de Oct. de 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.
2 comentarios
Star Strider
el 19 de Oct. de 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.
Más respuestas (1)
Walter Roberson
el 18 de Oct. de 2012
In the Symbolic Toolbox, the order of operands is treated algebraically, so any subexpression might get rewritten to an equivalent subexpression. For example, x*2*x would get rewritten to 2*x^2. When you replace dx*dy with dy*dx the order might get rewritten arbitrarily.
I do not know the order used by the Symbolic Toolbox. In another package I am familiar with, the order used is the order the operands were first encountered in (or so it used to be; the package added new controls around this in later releases.)
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!