Home > data-utility > fix_cstream.m

fix_cstream

PURPOSE ^

This is a function for fixing cstream that has gaps in it and fill them with number so that we have a full stream

SYNOPSIS ^

function new_cstream = fix_cstream(cstream, filler)

DESCRIPTION ^

 This is a function for fixing cstream that has gaps in it and fill them with number so that we have a full stream
 Assume that the range is evenly spaced
 Compute total range

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function new_cstream = fix_cstream(cstream, filler)
0002    % This is a function for fixing cstream that has gaps in it and fill them with number so that we have a full stream
0003    % Assume that the range is evenly spaced
0004    % Compute total range
0005    
0006    step = cstream(2,1) - cstream(1,1);
0007    new_cstream = zeros(round((cstream(end,1) - cstream(1,1))/step + 1),2);
0008    %cstream(end,1) - cstream(1,1))/step + 1
0009    % length(new_cstream)
0010 
0011    % Fill in range
0012    for i=1:length(new_cstream)
0013       new_cstream(i,1) = cstream(1,1) + (i-1) * step;
0014    end
0015 
0016    %[new_cstream(1,1) cstream(1,1) new_cstream(end,1) cstream(end,1)]
0017    % new stream index
0018    j = 0;
0019    % Move along old stream
0020    for i = 1:length(cstream)
0021       j = j + 1;
0022       while(abs(cstream(i,1) - new_cstream(j,1)) > step/4)
0023          %[i j cstream(i,1) new_cstream(j,1)]
0024          % Find hole just add filler and move on
0025          new_cstream(j,2) = filler;
0026          j = j +1;
0027       end
0028       % copy the value
0029       new_cstream(j,2) = cstream(i,2);
0030 
0031    end
0032 end

Generated on Tue 23-May-2017 03:00:58 by m2html © 2005