필터 지우기
필터 지우기

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