Q:

How to merge vectors of different length in an alternating manner

I'm trying to do the following in matlab. The numbers given are just an example. I am working with very large datasets, so an elegant solution is preferable.
I have two vectors where one is a single digit larger than the other:
a = [3  6 8 2 4 86 64 3]' %// 8 digits

b = [23 5 7 2 8 4  5]' %// 7 digits

I would like to combine them in an alternating fashion so they become:
c = [3 23 6 5 8 7 2 2 4 8 86 4 64 5 3] %// 15 digits

can anyone help with this?

A:

c(1:2:2*numel(a)-1) = a;
c(2:2:end-1) = b;

An alternative (I doubt it would be more efficient but you can test it out on your real data)
c = [a'; [b', NaN]];
c(:);
c(end) = [];

