Error in using syms

1 visualización (últimos 30 días)
Mohammed Tohifah
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);
Error in sym (line 229)
S.s = tomupad(x);
Error in transform (line 22)
if ~isa(f, 'sym'), f = sym(f); end
Error in sym/laplace (line 28)
L = transform('symobj::laplace', 't', 's', 'z', F, varargin{:});
What should I change in this so that I get the required output?

Respuesta aceptada

Star Strider
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.

Más respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by