What is wrong with this sequence?

I was given this code to figure out what is wrong with it, but cannot figure it out.
if true
% code
% Evaluate a sequence
% x_i = 4 * x_i-1 + 2 * x_i - 2
x = zeros(1,30);
x(1) = 10;
x(2) = 20;
for k = 1:length(x);
x(k) = 2.*x(k-2)-3.*x(k-1);
end
end

1 件のコメント

Cedric
Cedric 2015 年 8 月 11 日
編集済み: Cedric 2015 年 8 月 11 日
What happens when k is equal to 1 or 2 ?

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

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 8 月 11 日
編集済み: Azzi Abdelmalek 2015 年 8 月 11 日

0 投票

When k=1, k-2 is negative, and k-1 is equal to zero

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

タグ

質問済み:

2015 年 8 月 11 日

編集済み:

2015 年 8 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by