I am having trouble setting up my For loop ?
Ältere Kommentare anzeigen
I am trying to create a Matlab function that computes A inverse for a given NxN invertible matrix. but I am having trouble with my code. Exactly, in the For loop part of it
function my_inverse
rand('seed',1);
A = rand(100,100);
B = zeros(100,100);
[L, U, p]= lu_fac_pp(A);
for j = 1:100
%compute b1,b2...b100 ------> B
c=perm_b(b,p);
d=ultt_sys(L,c);
x=utt_sys(U,d);
B=x;
end
%check for accuracy
I = eye(100);
C =abs(A*B-I);
disp('max_entry & |A*B-I| using my_inverse');
max(max(C))
disp('----------------');
B = inv(A);
C = abs(A*B-I);
disp('max_entry & |A*B-I| using MATLAB');
max(max(C))
disp('------------------');
end
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Data Type Identification finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!