Reputation: 382
I currently have a large single row array of chars... I also have two arrays, the first array has all the start indexes of data I would like to retrieve from the char array, the second array has all the end indexes for the data. How can I retrieve all these wanted values from my char array without using a loop?
So far I have tried doing
chararray(1,start(:):end(:))
but this will only retrieve the first value I would like!
Cheers!
Upvotes: 1
Views: 106
Reputation: 221554
Try this -
chararray(bsxfun(@plus,start1(:)-start1(1),start1(1):end1(1)))
This would create a 2D char array where each row be the output from each iteration of your loop code.
Also, please note that I am using start1
and end1
to represent your start
and end
arrays respectively, so as not to create a clash with the reserved terminate scope end
used by MATLAB.
Upvotes: 2