I am completely new to MATLAB.This may be a rather basic question.
Given numerical values for size
, extras
and max
, I need to initialize a 1 X N vector such that the first size
elements are 1, the next size
are 2, the next size
are 3 and so on till the last size
elements are set to max
. So I need to initialize size
number of elements successively to x
such that x
increments from 1 to max
. The extras are the number of leftover cells which are initialized to 0. To illustrate:
size = 3; %# (is same as the quotient of N/max)
extras = 1; %# (is same as remainder of N/max)
max = 3;
N = 10;
original_vector = [0 0 0 0 0 0 0 0 0 0];
The desired output is
Required_vector = [1 1 1 2 2 2 3 3 3 0]