Second order ODE with dsolve
1 回表示 (過去 30 日間)
古いコメントを表示
Hello All,
Trying to solve this ODE.
clear,clc
syms y(t) x2(t) x1(t) a b
dy=diff(y,t);
ode = diff(y,t,2) == a.*d) + b.*y - diff(x2,t)./10 + x1;
cond1 = y(0)==0;
cond2 = dy(0)==0;
conds=[cond1 cond2];
sol1=dsolve(ode,conds)
t=(0:.1:20);
x2(t)=20.*heaviside(t);
x1(t)=0;
out=eval(sol1);
plot(t,out)
%%%% Getting this error %%%%
Error using eval
Must be a string scalar or character vector.
Error in Homework_1 (line 14)
out=eval(sol1);
0 件のコメント
採用された回答
Walter Roberson
2020 年 1 月 25 日
ode = diff(y,t,2) == a.*d) + b.*y - diff(x2,t)./10 + x1;
You are missing a ( . Also, dy is not defined. Perhaps d) is intended to be dy ?
You have two differential functions, y and x2, but you are only sending one equation to dsolve() . You need at least one equation for each function .
Or... you could define x2 before you define ode, so that ode becomes an equation with only one differential variable.
out=eval(sol1);
eval() is not defined for symbolic expressions. It does something in new enough releases, but the something it does is almost never what you would like to have happen. Use subs() instead.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!