MATLAB: Sequencing, matrix values and calling function

call inputmatrixsequencesequencing

Lets say I have
A=[1 0 0;1 1 0;0 1 0], I=[1 0;0 1], F=[1 2;2 1]
matrix, and like this code:
for i=1:3
B=0;
for j=1:3
B=B+A(i,j)
end
if B==1;
R(i)= I
else B==2;
R(i)=F
end
end
….. this code is not working, but output should be like this
R1=[1 0;0 1], R2=[1 2;2 1], R3=[1 0;0 1].
Please can anyone help…

Best Answer

A=[1 0 0;1 1 0;0 1 0], I=[1 0;0 1], F=[1 2;2 1]
ii = sum(A,2);
z = {I,F};
out = z(ii);