I am allowed to use the for loop as well as if/elseif/else statements to create the function but I am not sure how exactly to do this. The input will be a matrix A and a scalar value n. I began using if statements to make sure that the matrix is 2×2 and that n is positive however i do not know how to code for det(A^n) without using the det function. Below is an example of what i have thus far:
function ret = invertiblePowers(A,n) if isequal(size(A), [2 2])==0 ret= disp('Matrix has wrong dimensions') elseif floor(n)~=ceil(n) ret= disp('n is not a positive integer') elseif isequal(size(A), [2 2])==1 & floor(n)=ceil(n)
Best Answer