0

In MATLAB I have extracted a vector of indices corresponding to non-zero values. My vector - we can call idx - is of type double and of size 5x1 (for example) and looks something like this:

33 71 81 120 132

I have also made an empty vector of type double and of size length(idx)*4 so, in this example it is of size 20x1 and it is filled with zeros.

What I would like to do is increment every value in 'idx' by 1, 2, and 3 and add those numbers to the empty array after the idx value. So for example the new array would look like:

33 34 35 36 71 72 73 74 etc...

Is there a way to do this? Thank anyone for their help.

1 Answer 1

1

I would make

reshape([idx + [0 1 2 3]'],[1 length(idx)*4])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.