From charlesreid1

Comparison between syntax/operations in Matlab/Octave and D3, with an eye toward arrays and other data structures.

Loading Data

Loading Data Without Headers

One Dimensional Array

Give a sample csv file

Matlab/Octave:

A = load('file.dat');

D3:

d3.text(

Two Dimensional Array


Matlab/Octave:


D3:


Loading Data With Headers

One Dimensional Array

Give an example file

Matlab/Octave:

Load it into a cell?
Or how?

D3:

d3.csv(

Two Dimensional Array

Example file

Matlab/Octave:


D3:


Array Manipulation

Looping Through Elements of Array

One Dimensional Array

Example file

Matlab/Octave:


D3:


Two Dimensional Array

Example file

Matlab/Octave:


D3:


Slicing Two Dimensional Array

Grabbing Single Column

Example file

Matlab/Octave:

A(:,5)

D3:

array.map( function(d) { return d[5] } );

Grabbing Single Row

Example file

Matlab/Octave:

A(5,:)

D3:

array[0]

Grabbing Sub-Array

Example file

Matlab/Octave:

A(3:5,4:10)

D3:

array.slice()