Error in using syms
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Mohammed Tohifah
el 18 de Abr. de 2021
Respondida: Star Strider
el 18 de Abr. de 2021
So I have this code
syms x t s X F
F=laplace('diff(x(t),t,t)+5*diff(x(t),t)+610*x(t)-exp(-t)',s);
F=subs(F,{'laplace(x(t),t,s)'},{X});
F=subs(F,{'x(0)','Dx(0)'},{0,0});
x=solve(F,'X');
x=ilaplace(x);
I'm using Matlab 2020a. It gives me this error:
Character vectors and strings in the first argument can only specify a variable or number. To evaluate character vectors and strings representing symbolic expressions, use 'str2sym'.
S = convertChar(x);
S.s = tomupad(x);
if ~isa(f, 'sym'), f = sym(f); end
L = transform('symobj::laplace', 't', 's', 'z', F, varargin{:});
What should I change in this so that I get the required output?
0 comentarios
Respuesta aceptada
Star Strider
el 18 de Abr. de 2021
Remove the single quotes, define ‘x’ as ‘x(t)’, and define ‘Dx’ (and ‘D2x’ if you want to), explicity:
syms x(t) t s X F
Dx = diff(x);
D2x = diff(Dx);
F=laplace(D2x+5*Dx+610*x(t)-exp(-t),s);
F=subs(F,{laplace(x(t),t,s)},{X});
F=subs(F,{x(0),Dx(0)},{0,0});
x=solve(F,X);
x=ilaplace(x)
producing in LaTeX format —
The code is otherwise unchanged.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!