intercalar03

Intercalates the elements of 2 or more vectors to form one row vector

You are now following this Submission

This file contains a simple function of the form:
[TT,T]=intercalar03(A,B,C,...)

Where if

A=[a1 a2...an]; B=[b1 b2...bn];
c=[c1 c2...cn]

Then TT=[a1 b1 c1 a2 b2 c2...an bn cn]

It also works if any of B,C,D... is an escalar. Thus, if C is an escalar c, then C=[c c c...c] is taken to have the same number of elements A has.
Not only it works with numbers, but with any kind of variable that accepts a simple array manipulation. (i.e. char or sym, but not inline objects)

The idea is simple, and many others might have used that before:

1. Create the matrix T=[A; B; C;...]
2. Read it's columns as T(:).'

Usage: I have used it to generate discontinuous plots by intercalating the coordinates with Nan. The file includes an example of this.
Note: I was not capable of avoiding the loop to create the matrix TT, since there is a variable number of input arguments. How can that be done?

Cite As

Miguel D. B. (2026). intercalar03 (https://www.mathworks.com/matlabcentral/fileexchange/10323-intercalar03), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0