MATLAB: Use a for loop for fill this array with the first ten elements of the recursive sequence, then output this array

MATLABrecursive sequence

This is more information about the problem: a_1= 1, a_2 = -3, a_n =2_a_(n-1)-3_a_(n-2).
This is what I have come up with so far: a(1)=1; a(2)=(-3); for n=2:10 a(n)=2*(a(n-1))-3*(a(n-2)); end

Best Answer

You have already defined the first two elements of ‘a’, so begin the loop at 3 instead:
for n=3:10
a(n)=2*(a(n-1))-3*(a(n-2));
end