0

I have a vector, F0, with values I need to study. The vector f0 can be separated into sections A&B, A_starts has the indexes where sections of A start and A_ends has the indexes where A ends, the resulting elements of F0 are B. How can I extract the elements A and B from F0?

I tried the following but I only got the elements from the first occurrence of the section.

A=F0(starts_A:ends_A);

An example of the dataset:

F0: 110 6 7 101 105 3 5 1 109 9 8 7 6 108

starts_A: 2, 6, 10

ends_A: 3, 8, 13
  • 1
    You could process each pair of elements in `starts_A` and `ends_A` in a `for` loop. Something like `for ii = 1:numel(starts_A); F0(starts_A(ii):ends_A(ii), end;`. – mikkola Oct 21 '17 at 14:24
  • Possible duplicate of [Matlab - Accessing a part of a multidimensional array](https://stackoverflow.com/questions/45198046/matlab-accessing-a-part-of-a-multidimensional-array) – Leander Moesinger Oct 21 '17 at 15:06

0 Answers0