I am trying to apply the steps attached to the pdf file into my code

1 回表示 (過去 30 日間)
daniel choudhry
daniel choudhry 2020 年 10 月 5 日
回答済み: Alan Stevens 2020 年 10 月 5 日
1.I am having trouble trying to put the steps attached to the pdf file into my matlab code.
2. After translating the steps from the pdf file I would have to put this into command window in order to generate my answer:
>> rand('seed',1)
>>A=rand(10,10);
>>d=my_det(A)
>>dd=det(A)
>>abs(d-dd)/abs(dd)
3. lu_fac_pp(A) is another function i am calling witin this code.
function d = my_det(A)
n = size(A,1);
p=(1:n)';
tr = zeros(1,n);
s=0;
[L, U, p]= lu_fac_pp(A)
for k = 1:n-1
if A(n,n) == 0
det(A)=0;
end
[r m]=max(abs(A(k:n,k)));
m=m+k-1;
if (A(m,k)~=0)
if (m~=k)
A([k m],:)=A([m k],:);
p([k m])=p([m k]);
end
i=k+1:n;
A(i,k)=A(i,k)/A(k,k);
j=k+1:n;
A(i,j)=A(i,j)-A(i,k)*A(k,j);
end
end
if A(n,n) ==0
disp('A is not invertible');
return
end
L=tril(A,-1)+eye(n,n);
U=triu(A);
end

採用された回答

Alan Stevens
Alan Stevens 2020 年 10 月 5 日
Your function starts with
function d = my_det(A)
but, nowhere within it is there any calculation of d, so the function doesn't return anything.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePhase-Locked Loops についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by