如何在Matlab中创建此向量?我需要你的帮助。
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
答案 0 :(得分:1)
分两行
v = reshape([repmat((1:50)',1,5) zeros(50,2)]',1,[]);
v(end-1:end) = []
答案 1 :(得分:0)
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