MATLAB: How to add a number in a matrix in a loop

loopMATLABmatrix

I'll give an example of what i have to do.
I need this:
A=[1 0
3 0
5 0];
B=zeros(2*length(A),2);
for i=1:length(A)
%Then that's my problem:
%for i=1, i need:
B=[1 1
3 0
5 0];
%for i=2, i need:
B=[1 0
3 1
5 0];
%and for i=3, i need:
B= [1 0
3 0
5 1];
How can i do that? I just got B= [1 1;3 1;5 1]
Please, help me!
Thank you, everybody!

Best Answer

A=[1 0
3 0
5 0];
nrow = size(A,1);
B = A;
for K = 1 : nrow
B(:,2) = 0; B(K,2) = 1;
...
end
Related Question