What is wrong with this sequence?
Show older comments
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 Comment
Answers (1)
Azzi Abdelmalek
on 11 Aug 2015
Edited: Azzi Abdelmalek
on 11 Aug 2015
0 votes
When k=1, k-2 is negative, and k-1 is equal to zero
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!