Hi everbody
I should create a matrix by using number of element of any gap like as the example:
If gap has:
3 elements, matrix: [1 1 2]
4 elements, matrix: [1 1 2 2]
7 elements, matrix: [1 1 2 2 3 3 4] etc.
and matrix includes only 1 2 3 4 numbers, same numbers must be two side by side.
Is there any way for this operation?
Thanks…
Edit:
I have just created a loop for this operation:
for ... elements=[1 1 2 2 3 3 4 4]; if numel(gap)<=numel(elements); matrix=elements(1:numel(gap)); end if numel(gap)>numel(elements); diff=(numel(gap)-numel(elements)) matrix=[elements linspace(4,4,diff)] endend
Best Answer