Collect different symbolic variables under the same exponent
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Edoardo Fornari
el 2 de Nov. de 2020
Comentada: Edoardo Fornari
el 7 de Nov. de 2020
I have 2 symbolic variables 'a' and 'b', and an exponent 'm'. At the end of some calculations the symbolic expression that Matlab provides is in the form:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/400929/image.png)
I want to ask if there is a function that allow me to rewrite it in the form:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/400934/image.png)
I know that I can do it by hand, but I have at least 200 terms to rewrite in this way.
Thanks very much for the help.
0 comentarios
Respuesta aceptada
Kiran Felix Robert
el 5 de Nov. de 2020
Hi Edoardo,
Refer the expand function, and Children function documentation. Refer link for various other Functions to Rearrange Symbolic Expressions.
The Following code shows an example for your use case,
syms a b m y
y = (a^m/b^(m+2));
y = expand(y);
[N,D] = numden(y);
D_Split = children(D);
T1 = N/D_Split(1); % (a/b)^m
T2 = 1/D_Split(2); % (1/b^2)
Kiran Felix Robert
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!