필터 지우기
필터 지우기

Breaking equations down into parts while retaining output

조회 수: 1 (최근 30일)
GratefulLed
GratefulLed 2021년 2월 8일
편집: GratefulLed 2021년 2월 8일
Greetings, I am new to Matlab and have some novice level programming experience. I am working on a lengthy equation that involves a lot of parantheses and it is getting tough to keep them all straight and make sure they're in the right place. I thought it would help if I could break the equation down into smaller parts. To simplify that idea, as an exercise, I made this code below:
syms a rational positive integer
syms b rational positive integer
syms c rational positive integer
syms d rational positive integer
syms atimesb rational positive integer
syms ctimesd rational positive integer
syms MyTotal rational positive integer
eqn = atimesb == a * b
eqn = ctimesd == c * d
eqn = MyTotal == atimesb + ctimesd
I was hoping the output (on the right side in Matlab) for MyTotal would be: eqn = MyTotal = ab + cd
However, the output I'm getting is: eqn = MyTotal == atimesb + ctimesd
Do I need to use a function to get they type of output I'm looking for? Is there any other way than using a function? Can anyone help by showing me an example?

채택된 답변

madhan ravi
madhan ravi 2021년 2월 8일
atimesb = a * b;
ctimesd = c * d;
eqn = MyTotal == atimesb + ctimesd
  댓글 수: 1
GratefulLed
GratefulLed 2021년 2월 8일
편집: GratefulLed 2021년 2월 8일
Amazing, thanks so much! It's like learning a new language (actually, it is learning a new language haha)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by