A = [ -1 0 -2 0 0
2 8 0 1 0
0 0 3 0 -2
0 -3 2 0 0
1 2 0 0 -4];
a=size(A);
b=size(A);
c=0;
position=0;
for i=1:a
for j=1:b
if A(i,j) ~=0
c=c+1;
position=position+1;
S(c,:)=[position,i,j,A(i,j)];
end
end
end
index=size(S,1);
NIR = [];
for i = 1:index
for j = 1:index
if i ~= j
if S(i,2) == S(j,2)if S(i,3) < S(j,3)if length(NIR) < i
NIR(i,1) = S(j,1);
end
end
end
end
end
if length(NIR) < i
NIR(i,1) = 0;
end
end
%finding NIC
NIC = [];
for i = 1:index
for j = 1:index
if i ~= j
if S(i,3) == S(j,3)if S(i,2) < S(j,2)if length(NIC) < i
NIC(i,1) = S(j,1);
end
end
end
end
end
if length(NIC) < i
NIC(i,1) = 0;
end
end
Sprs=[S,NIR,NIC]
n=nnz(A);
r=size(A);
m=r(1,1);
position=zeros(n,1);
t=1;
FIR= zeros(m,1);
FIC= zeros(m,1);
for i= 1: n
position(i,1)= i;
end
for i= 1: m
for j= 1: m
if (A(i,j)~= 0)
value(var,1)= A(i,j);
row(var,1)= i;
col(var,1)= j;
var= var+ 1;
end
end
end
for j= 1: m
for i= t: n
if row(i,1)== j
FIR(j,1)= position(i,1);
t= i+1;
break;
end
end
end
for k= 1: m
for l= 1: n
if (col(l,1)== k)
FIC(k,1)= position(l,1);
break;
end
end
end
S1=[FIR, FIC]