How do I extract the function from a piecewise defined function in Matlab?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Benjamin Marrow
el 31 de Ag. de 2017
Respondida: Walter Roberson
el 1 de Sept. de 2017
I'm using the new Matlab piecewise function https://www.mathworks.com/help/symbolic/piecewise.html introduced in the Symbolic Math Toolbox R2016b to define a function, and I'm trying to extract the function expression part from the whole piecewise variable. Specifically my code looks something like:
syms x;
y = piecewise(x>1,3*x^2,0);
I'd like to be able to extract just the
3*x^2
from y without the condition.
Any idea how to do that?
1 comentario
Nicolas Schmit
el 1 de Sept. de 2017
Hello. Assume x>1 then simplify the expression.
syms x
y = piecewise(x>1,3*x^2,0);
assume (x>1);
simplify(y)
Respuesta aceptada
Walter Roberson
el 1 de Sept. de 2017
You can use children() to extract the subexpressions of a symbolic expression.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Assumptions en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!