Be the first to rate this file! 0 Downloads (last 30 days) File Size: 1.9 KB File ID: #10323

intercalar03

by Miguel D. B.

 

11 Mar 2006 (Updated 13 Mar 2006)

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

| Watch this File

File Information
Description

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?

MATLAB release MATLAB 5.3 (R11)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
intercalate Miguel D. B. 22 Oct 2008 08:18:13
array Miguel D. B. 22 Oct 2008 08:18:13
vector Miguel D. B. 22 Oct 2008 08:18:13
plot Miguel D. B. 22 Oct 2008 08:18:13
interpose Miguel D. B. 22 Oct 2008 08:18:13
insert Miguel D. B. 22 Oct 2008 08:18:13

Contact us at files@mathworks.com