Extending the values of a vector
Show older comments
I have a vector of size 1*6 with values A=[2 14 6 18 9 10].Now i want to convert this vector to another vector of size 1*12(for suppose) with the values to be distributed across the vector. Like for decreasing the vector we are having accumarray (In that it will add the values in the same indices) .
2 Comments
Guillaume
on 27 Feb 2018
It's a shame that whichever answer that had a very long list of comments got deleted, as all the context for the remaining answers is now missing.
Please, whoever deleted their answer, don't delete answers that have a long discussion attached to it as that discussion was very useful in explaining what was wanted.
Jyothi Alugolu
on 27 Feb 2018
Accepted Answer
More Answers (1)
Guillaume
on 23 Feb 2018
A=[2 14 6 18 9 10]
half1 = arrayfun(@(v) randi(v-1), A);
full = [half1, A-half1]
result = full(randperm(numel(full)))
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!