How to replace a range in one array at a specific location using the value of another array to determine where?
Show older comments
I have two arrays (both are 1 column):
- ArrayZeros - this array is filled with 400,000 zeros.
- ArrayInput - this array has 20 values.
My goal is iterate through ArrayInput and use those numbers to determine were in ArrayZeros I should replace with the number '4'. This number in ArrayInput would be the start location, and I want to replace 20 0's with 20 4's. For example, if ArrayInput's first number is 8 then I want to go to the eighth location in ArrayZeros and replace with a 4 and continue until the 28th zero. This will change ArrayInput from 8-28th location to 4's. I would want to keep iterating through ArrayInput and continue to change ArrayZeros.
Accepted Answer
More Answers (0)
Categories
Find more on Matrices and Arrays 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!