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 Related SolutionsMATLAB: I want to make every row have same number TryA = repmat((1:N)', [1, N]) MATLAB: Fibonacci sequence, slightly different. Looks like your indexing into seq is not quite right. Try this: seq(k)=seq(k-1)+begin; Related QuestionDisplay while loop output as an arraySum in sequence, string, matrixAdding elements to an arrayHow to add array of data into a variable?says i wanna loop for 4timesMonts in year sequence, string, matrixIndex exceeds matrix dimensions errorCreating array from binary sequence, and certainly with the calculation of the dimension
Best Answer