n=6;
h(:,:,1) = [0 1 2 1 2 3;
1 0 1 1 2 2;
2 1 0 2 1 1;
1 1 2 0 1 2;
2 2 1 1 0 1;
3 2 1 2 1 0];
h(:,:,2) = [0 2 3 2 3 4;
2 0 3 2 3 3;
3 3 0 3 2 2;
2 2 3 0 3 3;
3 3 2 3 0 2;
4 3 2 3 2 0];
for i = 1:n
for j = 1:n
if i ==n && j == n
fprintf('%d %d %d %d;\n', i, j, h(i,j,1),h(i,j,2));
else
fprintf('%d %d %d %d\n', i, j, h(i,j,1),h(i,j,2));
end
end
end
it give me the result like
1 1 0 0
1 2 1 2
1 3 2 3
1 4 1 2
1 5 2 3
1 6 3 4
2 1 1 2
2 2 0 0
2 3 1 3
.....
6 6 0 0;
..........................
i want to get expected result like
1 1 1
1 2 1
1 3 1
-----
6 6 1
1 1 2
1 2 2
1 3 2
----
2 1 2
2 2 2
----
6 6 2
the actual results print the value of i, j and h1(i,j) and h2(i,j) but actually i dont want to print the value of h1,h2 with respect to i, j but i want to print the results i,j and the index of h. Kindly guide me in this regards,
thank you