필터 지우기
필터 지우기

How to simplify one expression without Negative(-) mark

조회 수: 3 (최근 30일)
CrossFire
CrossFire 2024년 5월 1일
답변: Walter Roberson 2024년 5월 7일
How to simplify the belowing expression B without the - mark?
I thought the result should be :
but, the result always show the MINUS sign mark.
clc;clear;
syms Z_1 Z_2 Z_3 Z_4 I_1
% (a) V_1
V_1 = I_1 * (Z_1*Z_2/(Z_1+Z_2) + Z_3*Z_4/(Z_3+Z_4));
% (b) I_Z1
I_Z1 = Z_2/(Z_1+Z_2)*I_1;
% (c) I_Z3
I_Z3 = Z_4/(Z_3+Z_4)*I_1;
% (d) I_2
I_2 = I_Z1 - I_Z3;
% (e) B
B = V_1/I_2;
% (f) D
D = I_1/I_2;
simplify(B)
ans = 
  댓글 수: 2
Torsten
Torsten 2024년 5월 1일
Hint: Look at the denominator.
CrossFire
CrossFire 2024년 5월 7일
@Torsten Thanks so much!
I refered your idea using function numden, and got the denominator result that I wanted!
% to get the denominator from B
[n d]=numden(B)

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

채택된 답변

Walter Roberson
Walter Roberson 2024년 5월 7일
MATLAB Symbolic Toolbox automatically re-arranges expressions into "canonical form" in order to make it simpler to share parts of expressions (which in turn makes it more efficient to process expressions, since the repeated parts only have to be processed once.)
The canonical form for polynomials involves sorting each term in alphabetical order, then sorting the terms in alphabetical order, modified by the rule that the first term must normally have a positive coefficient. You can only get a leading negative if all of the terms are negative
>> -Z1+Z_1 - Z10 - Z_10
ans =
Z_1 - Z10 - Z1 - Z_10
>> -Z1-Z_1 - Z10 - Z_10
ans =
- Z1 - Z10 - Z_1 - Z_10
However, when forming rationals, the rule is a bit different: if the leading term of the denominator (as determined by sorting in alphabetical order) would normally be negative, then the negative of the denominator is formed, and the negative of the numerator is taken.
Your denominator is Z_2*Z_3 - Z_1*Z_4 which would sort into -Z_1*Z_4 + Z_2*Z_3 . Because it is the demonator, the negative is taken forming Z_1*Z_4 - Z_2*Z_3 and the negative of the numerator is taken. All of the terms of the numerator are then negative so you get the leading negative together with all positive terms.
You cannot get it to show you the denominator as Z_Z*Z_3 - Z_1*Z_4 because that would violate the rule that for denominators the terms are always sorted alphabetically

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by