Solve out a symbol

1 visualización (últimos 30 días)
Pouyan Msgn
Pouyan Msgn el 7 de Jul. de 2019
Comentada: Pouyan Msgn el 7 de Jul. de 2019
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?

Respuesta aceptada

infinity
infinity el 7 de Jul. de 2019
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 comentario
Pouyan Msgn
Pouyan Msgn el 7 de Jul. de 2019
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

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by