Reputation: 23
How can i create this vector in Matlab? Please I need your help.
Vector = [1 1 1 1 1 0 0 2 2 2 2 2 0 0 3 3 3 3 3 ... 49 49 0 0 50 50 50 50]; %the vector
Upvotes: 1
Views: 45
Reputation: 23
B = 1:50;
C = repelem(B, 7)';
D = 0;
for j = 1:size(C)
D = D +1
if (mod(D, 7) == 0 || mod(D, 7)==6)
C(j) = 0;
end
end
Upvotes: 0
Reputation: 7751
In two lines
v = reshape([repmat((1:50)',1,5) zeros(50,2)]',1,[]);
v(end-1:end) = []
Upvotes: 1