Error being printed "Error using sym>convertChar (line 1557) 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'."

2 views (last 30 days)
syms s t Y
figure
ezplot(heaviside(t-3), [0 15]);
eqn = sym('D(D(y))(t) + 2*D(y)(t) + 3*y(t) = heaviside(t-3)');
lap= laplace(eqn, t, s);
eqn2= subs(lap, {'laplace(y(t),t,s)', 'y(0)', 'D(y)(0)'}, {Y,0,1});
ynew= solve(eqn2, Y);
y= ilaplace(ynew, s, t)
figure
ezplot(y, [0,15])
% In the graph, you can see that the forcing causes the graph to be
% sinusoidal from 0 to 3. Then the graph changes to aysmptotic to a value
% of .32.

Answers (1)

Steven Lord
Steven Lord on 16 Apr 2021
You could use str2sym as the error message suggested, but instead I would use one of the approaches shown on this documentation page or this one instead of the older D-based approach.

Tags

Community Treasure Hunt

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

Start Hunting!