Code covered by the BSD License  

Highlights from
Difference Matrix

Be the first to rate this file! 3 Downloads (last 30 days) File Size: 1.45 KB File ID: #27270

Difference Matrix

by Zachary Danziger

 

16 Apr 2010

Builds the matrix that takes the column-wise difference of another matrix when post-multiplied.

| Watch this File

File Information
Description

 D = diffMat(obs,type)

Creates a difference matrix, D, that when multiplied by by another matrix takes its difference over obs columns. The type is either 'circular' or 'none'. The defalt is 'none'.

 EXAMPLE
 B = [2:1:8;sin(linspace(0,pi,7))]
 B =
     2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000
          0 0.5000 0.8660 1.0000 0.8660 0.5000 0.0000

 D = diffMat(size(B,2));
 B*D
 ans =
    -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000
    -0.5000 -0.3660 -0.1340 0.1340 0.3660 0.5000

 B*diffMat(size(B,2),'circular')
 ans =
    -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 6.0000
    -0.5000 -0.3660 -0.1340 0.1340 0.3660 0.5000 0.0000

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File  
Everyone's Tags
difference, linear algebra, matrix
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.

Contact us