Setting a constraint for a symbolic solve with a system of equations ?
조회 수: 13 (최근 30일)
이전 댓글 표시
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
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
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
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
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.)
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!