I would like to re-write this efficiently in MATLAB.
n=3;
x=zeros(n);
y=x;
for 1=1:n
x(:,i)=i;
y(i,:)=i;
end
I tried to run it in MATLAB and get this output below
x =
1 0 0
1 0 0
1 0 0
y =
1 1 1
0 0 0
0 0 0
x =
1 2 0
1 2 0
1 2 0
y =
1 1 1
2 2 2
0 0 0
x =
1 2 3
1 2 3
1 2 3
y =
1 1 1
2 2 2
3 3 3
When hard-coded,
will do. If not (
narbitrary), you can use