what's wrong in my code?

1 回表示 (過去 30 日間)
Art dela vega
Art dela vega 2021 年 11 月 27 日
コメント済み: Yusuf Suer Erdem 2021 年 11 月 28 日

採用された回答

Yusuf Suer Erdem
Yusuf Suer Erdem 2021 年 11 月 27 日
編集済み: Yusuf Suer Erdem 2021 年 11 月 27 日
Hi Alesna, could you try my codes below? Good luck.
clc; clear; close all;
syms y(t) k t
Dy=diff(y);
k=sqrt(2);
ode=diff(y,t,2)==k*sin(k*t);
conds = [y(0)==6, Dy(0)==0];
ySol(t)=dsolve(ode,conds)
  4 件のコメント
Art dela vega
Art dela vega 2021 年 11 月 28 日
Yusuf Suer Erdem
Yusuf Suer Erdem 2021 年 11 月 28 日
Try these codes below. Good luck.
clc; clear; close all;
syms y(x)
Dy = diff(y);
ode = diff(y,x,2) == -5*diff(y,x)-4*y;
cond1 = y(0) == 1;
cond2 = Dy(0) == 0;
conds = [cond1 cond2];
ySol(x) = dsolve(ode,conds);
ySol = simplify(ySol);
ySol(1)

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 11 月 27 日
You created y as a symbolic function, syms y(t)
You try to assign to ySol(y) . But y is a function, and you cannot index by a function.
You could assign to ySol(t)
  1 件のコメント
Art dela vega
Art dela vega 2021 年 11 月 28 日
thank you sir, i found my mistakes on my codes. thank you for the help!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNumber Theory についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by