Finite difference problem with matlab 2014

Let's say I have a problem like this: det_t = 0.02, t = [0 : det_t : 1], z(t+det_t) = 3 * z(t) + 2* z(t-det_t), where z(t-det_t) is the value of z initially, z(t) is value of z after one time step and z(t+det_t) is the value of z after two time step. Now I have the values of z(0) = 1 and z(-det_t) = 0, how can I calculate z(1) without having to substitute the new value of z for 50 times? I am very new to matlab so please explain with very basic language, thank you the help!

 採用された回答

Massimo Zanetti
Massimo Zanetti 2016 年 10 月 8 日
編集済み: Massimo Zanetti 2016 年 10 月 8 日

3 投票

Your problem is equaivalent to this (without the variable t, which redundant here as it is used only for indexing purposes). Since your vector t has 51 elements and you are meant to find the last value of the sequence, you want to implement this:
%you are given the first two elements of a sequence
z(1)=0;
z(2)=1;
%to determine the k-th value of the sequence (k>2)
%you need z(k)=3*z(k-1)+2*z(k-2), therefore:
for k=3:51
z(k)=3*z(k-1)+2*z(k-2);
end
% your solution is
z(51)

2 件のコメント

Jimmy W
Jimmy W 2016 年 10 月 8 日
Thank you, now I have got the value, but how do I plot t vs z?
Jimmy W
Jimmy W 2016 年 10 月 8 日
Actually I have figured it out! Thank you!

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

その他の回答 (0 件)

カテゴリ

質問済み:

2016 年 10 月 8 日

コメント済み:

2016 年 10 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by