What is wrong with this sequence?
1 次查看(过去 30 天)
显示 更早的评论
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 个)
Azzi Abdelmalek
2015-8-11
编辑:Azzi Abdelmalek
2015-8-11
When k=1, k-2 is negative, and k-1 is equal to zero
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!