How to solve simultaneous equation?
6 ビュー (過去 30 日間)
古いコメントを表示
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/373646/image.jpeg)
I hope to solve this simultaneous equation for y.
but I have some errors.
So i input the following code in Matlab R2018b:
clear all
>> syms A R B C y w t;
>> p1 = y - C*( (sin(w*t) )^2 / (A + sqrt(R*y + B^2)));
>> sol = solve([p1 == 0], y, 'ReturnConditions', true);
>> sol = solve([p1 == 0], y);
Warning: Solutions are parameterized by the symbols: z1. To include parameters and conditions in the
solution, specify the 'ReturnConditions' value as 'true'.
> In solve>warnIfParams (line 475)
In solve (line 357)
Warning: Solutions are valid under the following conditions: (signIm(A*1i - (C*sin(t*w)^2*1i)/z1) == -1 |
A*z1 == C*sin(t*w)^2 & z1 ~= 0) & C^2*sin(t*w)^4 + A^2*z1^2 == R*z1^3 + B^2*z1^2 + 2*A*C*z1*sin(t*w)^2.
To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
> In solve>warnIfParams (line 482)
In solve (line 357)
No matter what i do i can't make this to work. It's very strange. Any help will be greatly appreciated. Thanks in advance.
0 件のコメント
採用された回答
Walter Roberson
2020 年 10 月 7 日
syms A R B C y w t;
eqn = y == C*( (sin(w*t) )^2 / (A + sqrt(R*y + B^2)));
[n,d] = numden(rhs(eqn));
ysol = solve(eqn * d, y, 'maxdegree', 3)
2 件のコメント
Walter Roberson
2021 年 6 月 9 日
syms A R B C y sinwt
eqn = y == C*( (sinwt )^2 / (A + sqrt(R*y + B^2)));
[n,d] = numden(rhs(eqn));
ysol = solve(eqn * d, y, 'maxdegree', 3)
yt = simplify(arrayfun(@(X) taylor(X, sinwt, 0, 'Order', 3), ysol))
ytn = combine(subs(yt, {A,R,B,C}, {sym('2.213'), sym('0.736'), sqrt(sym('0.182')), sym('10.')}))
ytn4 = vpa(ytn)
ytn4b = mapSymType(ytn4, 'number', @(v) piecewise(imag(v) > -1e-5 & imag(v) < 1e-5, real(v), v))
ytn4c = mapSymType(ytn4b, 'number', @(v) piecewise(real(v) > -1e-5 & real(v) < 1e-5, imag(v), v))
ytn4d = vpa(ytn4c,4)
The step of taking vpa(ytn) is crucial for combining various numeric expressions that individually use numbers large enough that they cannot reasonably be ignored, but which largely "cancel out"
The two steps using mapSymType() could be combined into one step, but it would be complicated to write, like "imaginary part is more negative than this or more positive than that but real part is less negative and less positive, then select the imaginary part without the real part". In my judgement, the result would be less clear than handling the two parts independently.
I use taylor order 3 here. If you use taylor order 4, you get exactly the same result -- the taylor output is exactly the same. If you use taylor order 5 or 6 then you get a sinwt^4 term, which you indicated that you do not expect.
Note that the fact that you do not expect sinwt^4 or higher order terms, does not mean that they are not significant.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!