Solve out a symbol

1 回表示 (過去 30 日間)
Pouyan Msgn
Pouyan Msgn 2019 年 7 月 7 日
コメント済み: Pouyan Msgn 2019 年 7 月 7 日
Hi I have the formula :
k=w*sqrt(e*m/2)*sqrt(sqrt(1+(s/(w*e))^2)-1)
And I will solve out s:
clc
clear all
syms k w m e s
k=w*sqrt(e*m/2)*sqrt(sqrt(1+(s/(w*e))^2)-1)
solve(k,s)
But the problem is this :
Warning: The solutions are valid under the following conditions: e ~= 0 & w ~= 0. To include parameters and
conditions in the solution, specify the 'ReturnConditions' option.
> In solve>warnIfParams (line 517)
In solve (line 360)
ans=0
Can I get s by using Matlab?

採用された回答

infinity
infinity 2019 年 7 月 7 日
Hello,
If you write
solve(k,s)
the solve function will solve another equation k == 0, i.e,
w*sqrt(e*m/2)*sqrt(sqrt(1+(s/(w*e))^2)-1) == 0
which is not what you want to solve. Also, obviously, s = 0 is the solution of this equation.
So, you may change your code litle bit as follows
clc
clear
syms k w m e s
f=w*sqrt(e*m/2)*sqrt(sqrt(1+(s/(w*e))^2)-1)
[sol,~,conditions] = solve(f==k,s,'ReturnConditions', true)
It will give the results
sol =
-(2*k*(k^2 + e*m*w^2)^(1/2))/(m*w)
(2*k*(k^2 + e*m*w^2)^(1/2))/(m*w)
conditions =
signIm((k*1i)/(w*((e*m)/2)^(1/2))) == 1 & signIm((k^2*2i)/(e*m*w^2) + 1i) == 1
signIm((k*1i)/(w*((e*m)/2)^(1/2))) == 1 & signIm((k^2*2i)/(e*m*w^2) + 1i) == 1
  1 件のコメント
Pouyan Msgn
Pouyan Msgn 2019 年 7 月 7 日
Thank you! I could also solve it by this way:
clc
clear all
syms k w m e s
eqn=k==[w*sqrt(e*m/2)*sqrt(sqrt(1+(s/(w*e))^2)-1)]
%k=1; e=0.0006; m=2000; w=2*pi*10^6;
sol=solve(eqn,s)
which gave me the same answer

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

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by