Filter löschen
Filter löschen

What is wrong with this sequence?

1 Ansicht (letzte 30 Tage)
Mark Dillon
Mark Dillon am 11 Aug. 2015
Bearbeitet: Azzi Abdelmalek am 11 Aug. 2015
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 Kommentar
Cedric
Cedric am 11 Aug. 2015
Bearbeitet: Cedric am 11 Aug. 2015
What happens when k is equal to 1 or 2 ?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 11 Aug. 2015
Bearbeitet: Azzi Abdelmalek am 11 Aug. 2015
When k=1, k-2 is negative, and k-1 is equal to zero

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by