Removing exponents from a sysm class term

조회 수: 2 (최근 30일)
ross montgomery
ross montgomery 2012년 10월 30일
I am interested in removing the exponents from a syms class object. For instance, i wish the following expression,
answer = x^2 + y^2*z^2
to instead take the form of,
answer = x + y*z
I was wondering if there was a shorter way to do this other than writing my own muPad procedure.
Thanks in advance.
Ross Montgomery

채택된 답변

Alexander
Alexander 2012년 10월 31일
You can use evalin to do a substitution of the powers inside MuPAD:
>> evalin(symengine, ['subs(', char(answer) ,', hold(_power) = (x->x), EvalChanges)'])
ans =
x + y*z
  댓글 수: 1
ross montgomery
ross montgomery 2012년 10월 31일
Hi Alexander,
This worked great and is exaclty what i was looking for.
Many thanks.
Ross

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 10월 30일
You might be able to do something using MuPad's map() and match(); http://www.mathworks.com/help/symbolic/mupad_ref/match.html
Side note: Extended Symbolic Math Toolbox only applied to the Maple-based Symbolic Toolbox which predated the MuPAD based Symbolic Math Toolbox.
  댓글 수: 1
ross montgomery
ross montgomery 2012년 10월 31일
Thanks for your response Walter and i'll stop tagging "Extended Symbolic Math Toolbox" on all of these problems.
Thanks again.
Ross

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Utilities for the Solver에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by