how to write a code second order diffrentiation code in MTLAB

1 回表示 (過去 30 日間)
Eshovo Moses
Eshovo Moses 2021 年 3 月 3 日
コメント済み: Eshovo Moses 2021 年 3 月 3 日
hello eveyone, please can someone help me out......I am trying to write a matlab code that can perform second order differentiation. below is my attempted code but it failed work. Thanking you in advance.
clear all;
close all;
st = -1;
inc=0.001;
en =1;
t=st:inc:en;
y= t.^3;
x=zeros(1,(length(i)-1));
for i=1:(length(t)-1);
x(1,i)=(y(1,i+2)-2*y(1,i+1)+y(1,i))./(inc.^2);
end
t1=st:inc:(en-inc);
figure(2)
plot(t1,x);
title('After differentiation')

採用された回答

KSSV
KSSV 2021 年 3 月 3 日
st = -1;
inc=0.001;
en =1;
t=st:inc:en;
y= t.^3;
x=zeros(1,(length(i)-2));
for i=1:(length(t)-2)
x(i)=(y(i+2)-2*y(i+1)+y(i))./(inc^2);
end
t1=st:inc:(en-inc);
figure(2)
plot(t1(1:end-1),x);
title('After differentiation')
  3 件のコメント
Eshovo Moses
Eshovo Moses 2021 年 3 月 3 日
YEs it works
Eshovo Moses
Eshovo Moses 2021 年 3 月 3 日
Thank you KSSV

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by