Insert elements of one vector into another in a specific order
Ältere Kommentare anzeigen
Hello everyone,
I have a vector A=[A1 A2 A3 ... A30876] of length(A)=30876 and a vector B=[B1 B2 B3 ... B497] of length(B)=497. In order to then solve a linear system, I first need to create a vector C of length(C)=length(A)+length(B) by inserting the elements of B into A like this:
C=[A1 A2 A3 ... A 124 B1 B2 A125 A126 ... A248 B3 B4 A249 A250 ... A372 B5 B6 A373 A374 ...] (and so on).
Basically, there have to be two elements of B after every 124 elements of A.
Thanks in advacne.
Note: This is actually the exact opposite of a question I asked a couple of weeks earlier here: https://www.mathworks.com/matlabcentral/answers/796337-rearrangement-of-vector-elements and I eventually solved using the concept of logical indexing suggested by Jan (not the exact same code though). Unfortunately, I did not manage to apply the same principle "backwards" to solve this issue.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!