Undefined function 'int' for input arguments of type 'char'. keep getting error using matlab2015b

1 回表示 (過去 30 日間)
Brenda Galabe
Brenda Galabe 2018 年 12 月 8 日
編集済み: Brian Hart 2018 年 12 月 8 日
eqa= 'diff(y(t),t)+y(t)-cos(t)';
neweq1a = laplace(eqa,t,s)
neweq1i = laplace(int('y(x)','x','0','t'),t,s)
neweq1 = neweq1a + neweq1i;
neweq2 = subs(neweq1,'y(0)',0)
lneweq2 = subs(neweq2,'laplace(y(t),t,s)',Ys)
soln = solve(lneweq2,Ys)
ysol = ilaplace(soln,s,t)

回答 (2 件)

Walter Roberson
Walter Roberson 2018 年 12 月 8 日
You probably do not have the Symbolic Toolbox installed.
Note that that code would not work in current versions of MATLAB (R2018a and later.) It should be modernized even for your version.
syms s x y(t) Ys
dy = diff(y(t), t);
eqa= dy + y(t) - cos(t);
neweq1a = laplace(eqa, t, s)
inty = int(y(x), x, 0, t);
neweq1i = laplace(inty, t, s)
neweq1 = neweq1a + neweq1i;
neweq2 = subs(neweq1, y(0), 0)
lapy = laplace(y(t), t, s)
lneweq2 = subs(neweq2, lapy, Ys)
soln = solve(lneweq2, Ys)
ysol = ilaplace(soln, s, t)
This still requires the Symbolic Toolbox, but has been rewritten to avoid needing to process character strings.

Brian Hart
Brian Hart 2018 年 12 月 8 日
編集済み: Brian Hart 2018 年 12 月 8 日
In the first line you define an eqution as a text string (in quotes). Then in the second line you pass that text string into the laplace function, which expects a symbolic function. See the help pages for laplace and syms.
I think your specified error comes from the third line. The function int also wants a symbolic function, not text (which is of type 'char').

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

製品


リリース

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by