Matalab: this code have errors can you please fix it or write a new one thank you so much ;) the code: Creates a tridiagonal matrix with diagonal d = (3,3,...,3)', superdiagonal % d1 =...


Matalab:


this code have errors can you please fix it or write a new one thank you so much ;)


the code:


Creates a tridiagonal matrix with diagonal d = (3,3,...,3)',


superdiagonal % d1 = (-2,-2,...,-2)' and subdiagonal d0 = (-1,-1,...,-1)'.


Plots the determinant of kxk tridiagonal matrices for k=1,2,...20.


Create a cell array to store tridiagonal matrices Ak.


A = cell(1,20);


A{1} = 3;


Create a vector to store the values of the determinant of Ak


Det = 3*ones(1,20);


Create matrices Ak using diag function


for k=2:20


A{k} = diag(-1*ones(k-1,1),-1)+diag(3*ones(k,1))+diag(-2*ones(k-1,1),1);


Det(k) = det(A{k});


end


Plot the determinants of Ak with log scale for the determinants.


semilogy(1:20,Det);


xlim([1 20]);


xticks(1:20);


grid on;


grid minor;


xlabel('\leftarrow k \rightarrow');


ylabel('\leftarrow det(A_k) \rightarrow');


title('Determinants of A_k vs k,


for k=1,2,...,20.');




May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here