Setting a constraint for a symbolic solve with a system of equations ?

21 ビュー (過去 30 日間)
Robert
Robert 2016 年 5 月 1 日
コメント済み: Walter Roberson 2016 年 5 月 2 日
So I'm fooling with the symbolic solver
And I'm getting returned values of 0X1 Im assuming that is because there is no solution?
I have a small system that is the component values of a analog filter.
I want to force one of the values "r" to = 5000 There are 4 equations and 4 unknowns however i want to force one of them to be = to a set value but still solve so all 4 equations are true?
How can i do this?
Here is what i got so far
syms C1 C2 C3 r
equations = cell(4,1); %creates a cell array
equations{1,1}='(1)/(C1*C2*C3*r*r*r)== 2.481e11'
equations{2,1}= '2*(1/C1*r)+3*(1/C2*r)==12570'
equations{3,1}='5*(1/C1*C2*r^2)+(1/C2*C3*r^3)== 7.896e07'
equations{4,1}='(2*r)/(C1*C2*C3*r^4)==2.481e11'
assume(r == 5000);
Solution = solve(equations{:});
Results are as follows which is obviously not true
Solution =
C1: [0x1 sym]
C2: [0x1 sym]
C3: [0x1 sym]
r: [0x1 sym]
Any ideas on how to make this work? I tried the help solve file but can't seem to find anything on setting restraints ?
  1 件のコメント
John D'Errico
John D'Errico 2016 年 5 月 2 日
編集済み: John D'Errico 2016 年 5 月 2 日
Be nice. Nothing I said in my answer was at all unfriendly. Just true.

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2016 年 5 月 1 日
"When you pass a string to solve() or to sym(), then the string is interpreted as a MuPAD expression. MuPAD uses '=' as the equation operator."
But also, there are no solutions. Your first equation is
(1)/(C1*C2*C3*r*r*r)== 2.481e11
your last is
(2*r)/(C1*C2*C3*r^4)==2.481e11
In that last one, the r on top cancels one of the r on the bottom, leaving the equation as
(2)/(C1*C2*C3*r^3)==2.481e11
so 2 * 1/(C1*C2*C3*r^3) = 2.481e11
but the first equation says
1 * 1/(C1*C2*C3*r^3) = 2.481e11
The right hand sides are the same and non-zero and the left is twice as much on one of the two as on the other. There can be no solution to this.
Not unless we assume that the 2.481e11 are both approximations to the correct values and that they are different values that happen to round to the same number... assuming the rounding has been really badly done, like one of them should "really" be on the order of 4.9E11. And even if that is the case, with the subexpressions being the same between the first and last equations, you really only have 3 equations for 4 variables so you cannot uniquely determine all of the variables at the same time.
  2 件のコメント
Robert
Robert 2016 年 5 月 1 日
編集済み: Walter Roberson 2016 年 5 月 2 日
I see your point and thank you for taking the time to answer
However I do not understand how this is remotely possible
Im using the butter() filter command in matlab to generate the values.
And the transfer function for this system is as follows. It comes from a table in a filter handbook so i doubt its wrong
All i did was equate them to generate the 4 equations
[numerator denominator ]= butter(3,1000*2*pi,'low','s');
G = tf(numerator,denominator);
G
G =
2.481e11
------------------------------------------
s^3 + 1.257e04 s^2 + 7.896e07 s + 2.481e11
Continuous-time transfer function.
So all i did was put the pieces together. How can there be no solution
Walter Roberson
Walter Roberson 2016 年 5 月 2 日
The matching parts are
-1/(C1*C2*C3*r^3) == 248050213442.398
1/(C1*r) + 1/(C1*r) + 1/(C2*r) + 1/(C2*r) + 1/(C2*r) == 12566.3706143592
1/(C1*C2*r^2) + 1/(C1*C2*r^2) + 1/(C1*C2*r^2) + 1/(C1*C2*r^2) + 1/(C1*C2*r^2) + 1/(C2*C3*r^2) == 78956835.2087148
(r+r)/(C1*C2*C3*r^4) == 248050213442.398
Those simplify as
-1/(C1*C2*C3*r^3) == 248050213442.398
2/(C1*r) + 3/(C2*r) == 12566.3706143592
5/(C1*C2*r^2) + 1/(C2*C3*r^2) == 78956835.2087148
2/(C1*C2*C3*r^3) == 248050213442.398
Your version had the wrong sign for the first equation and for the third your 1/ do not extend far enough:
equations{3,1}='5*(1/C1*C2*r^2)+(1/C2*C3*r^3)== 7.896e07'
would have had to have been
equations{3,1}='5*1/(C1*C2*r^2)+1/(C2*C3*r^3)== 7.896e07'
In any case, you can see that you have the same problem, that the -1/F of the first equation has to equal the 2/F of the fourth equation. That is not going to happen.
Assuming that the R and C refer to capacitors and resistors, since those are non-negative, the sign mismatch in the numerator implies that you are looking at the wrong formula.
However, it appears there is another potential explanation for te sign mismatch: if one or more of the capacitors are actually inductors then there would be a negative capacitance and you could potentially balance the signs for the numerator. But then you would still have a sign mismatch for the last term, so the conclusion would still have to be that you are using the wrong formula.

サインインしてコメントする。


John D'Errico
John D'Errico 2016 年 5 月 1 日
編集済み: John D'Errico 2016 年 5 月 1 日
You have4 equations in 4 unknowns. But then you want to add a "constraint". The fact is, a constraint is just an equation. A simple one, yes.
r = 5000;
You can't call it something else, and not have it still be an equation.
So in the end, you have 5 (FIVE) equations in 4 unknowns. Typically this is a situation where no exact solution exists. Wanting it to be different is nice, but of little real value. Hey, I've been wanting to see peace in the mid-East for a long time. Is wanting something sufficient? Of course not. No more than wanting to win a lottery is sufficient to win it.
So that solve returns no solution should not surprise you. You should be surprised if it did find a solution, as that would be a rare case! Unless one of your equations is actually dependent on the others that won't happen. (One rare exception - if you just happened to arbitrarily pick a value for r that was one of the solutions, then the constraint would effectively have been the redundant piece of information.)

Community Treasure Hunt

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

Start Hunting!

Translated by