Finite difference scheme and iteration what is wrong with my code? Please help me

1 回表示 (過去 30 日間)
OZGUR YILDIRIM
OZGUR YILDIRIM 2020 年 12 月 28 日
コメント済み: OZGUR YILDIRIM 2021 年 1 月 5 日
function Perturbation(x,N,epsilon)
clc
close all
x=10;
N=10;
M=10;
h=1/M;
alpha=1;
beta=-1;
epsilon=0.01;
dtau=1/N; % step size
tau = 0:dtau:4; % Calculates upto y(3)
w = sym(zeros(1,length(tau)));
t= sym(zeros(1,length(tau))); % initial condition
F_0 = @(r) r; % change the function as you desire
F_10 = @(r) 2*r;
F_11 = @(r) 3*r;
for i=1:(length(h)-1) % calculation loop
tk=i*tau;
t=tk;
w(0) = F_0(t(i));
w(1) = F_10(t(i))+F_11(t(i));
w(i+1) = w(i) + w(i-1)+x % main equation
end
  4 件のコメント
Asvin Kumar
Asvin Kumar 2021 年 1 月 5 日
https://www.mathworks.com/help/symbolic/subs.html Should do just that.
OZGUR YILDIRIM
OZGUR YILDIRIM 2021 年 1 月 5 日
Thank you very much.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by