How can I replace an expression in a symbolic function with a new symbolic variable?
34 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Savino Petrignani
am 4 Jul. 2018
Kommentiert: madhan ravi
am 6 Jul. 2018
Hello to everyone,
I am using the Symbolic Math Toolbox and, after some steps, I've obtained a very complex symbolic function f. In order to make it easier to read, I'd like to replace some terms of the function with new symbolic variables, but I don't know how.
For example, assuming that the f function is
f = sqrt(A^2 + A*B)
I want to replace the term A*B with a new symbolic variable C, so that
f = sqrt(A^2 + C)
How can I do that? Thanks in advance for your help.
0 Kommentare
Akzeptierte Antwort
madhan ravi
am 6 Jul. 2018
syms A B C
f = sqrt(A.^2+ A*B)
subs(f,A*B,C)
actually this works
2 Kommentare
Weitere Antworten (1)
Basil C.
am 4 Jul. 2018
I assume that this should be what you are looking for
function result= C(A,B)
result=A*B;
end
But use this before the function f = sqrt(A^2 + C)
2 Kommentare
Siehe auch
Kategorien
Mehr zu Assumptions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!