MATLAB: Buildind special vector? V(3)=V(6)=V(9)…=0 vectorvectorizationvectors How can I build V=[1 1 0 1 1 0 1 1 0 1 1 0….]vector.I want to put N value and it will reply me V vector.. Elements fo V will be V(3)=V(6)=V(9)…=0 Best Answer Another guess:V = ones(1, N);V(3:3:end) = 0; Related SolutionsMATLAB: Special sorting Do not use "input" as name of a variable, because it is a name of a built-in function.in = [2, 2, 5, 6, 6, 6, 1, 1, 1, 1, 4, 3, 3];out = cumsum([1, diff(a) ~= 0]);>> out = [1 1, 2, 3, 3, 3, 4, 4, 4, 4, 5, 6, 6] MATLAB: Create a logical matrix from numerical vector https://www.mathworks.com/help/nnet/ref/ind2vec.htmlfull( ind2vec(V+1).' )or,accumarray((1:length(V)).', V+1)ormaxV = max(V);LV = length(V);M = zeros(LV, maxV+1);M(V * LV + (1:LV).') = 1;or maxV = max(V); LV = length(V); M = zeros(LV, maxV+1); M( sub2ind(size(M), (1:LV).', V+1) ) = 1; Related QuestionSpecial legend for special bar plotCreating a special matrixCreate a matrix with numbers from vector90% Percentile of MatrixRaise the zeros in the vector up
Best Answer