Whenever i try so solve for 's' i get the same error:
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Germán Portellano Rodríguez
el 2 de Nov. de 2023
Comentada: Walter Roberson
el 2 de Nov. de 2023
syms s
G= 1/((s+2)*(s+1)*(s+3)*(s+7)^2)
K= -1/G;
dk=diff(K)
sol=eval(solve(dk==0,'Real',true))
eval(subs(K,s,sol))
Error using evalin
Unrecognized function or variable 'z'.
Error in sym/eval (line 13)
s = evalin('caller',vectorize(char(x)));
Error in PEC2122 (line 8)
sol=eval(solve(dk==0,'Real',true))
0 comentarios
Respuestas (2)
Walter Roberson
el 2 de Nov. de 2023
Never eval() a symbolic expression or symfun or symbolic matrix expression. There is no documented meaning for eval() of any of those. In practice, eval() of any of them is eval() of char() of them . Which is a problem because char() of a symbolic expression does not always result in MATLAB code.
syms s
G = 1/((s+2)*(s+1)*(s+3)*(s+7)^2)
K = -1/G;
dk = diff(K)
sol = vpa(solve(dk==0,'Real',true))
vpa(subs(K,s,sol))
1 comentario
Walter Roberson
el 2 de Nov. de 2023
By the way, you can get exact solutions for this system:
syms s
G = 1/((s+2)*(s+1)*(s+3)*(s+7)^2)
K = -1/G;
dk = diff(K)
sol = solve(dk==0,'Real',true, 'maxdegree', 3)
simplify(sol)
Dyuman Joshi
el 2 de Nov. de 2023
Avoid the use eval as much as possible. And it is not required here.
syms s
G = 1/((s+2)*(s+1)*(s+3)*(s+7)^2);
K = -1/G;
dk = diff(K);
sol = solve(dk==0, 'Real', true)
sol = vpa(sol)
subs(K,s,sol)
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!