next up previous [pdf]

Next: Compiling Up: Fomel: RSF API Previous: Compiling

MATLAB interface

The MATLAB clip function is listed below.

function clip(in,out,clip)
%CLIP Clip the data

dims = rsf_dim(in);
n1 = dims(1);           % trace length
n2 = prod(dims(2:end)); % number of traces
trace = 1:n1;           % allocate trace
rsf_create(out,in)      % create an output file

for i2 = 1:n2           % loop over traces
    rsf_read(trace,in,'same');
    trace(trace >   clip) =  clip;
    trace(trace < - clip) = -clip;
    rsf_write(trace,out,'same');
end

Let us examine it in detail.

dims = rsf_dim(in);
We start by figuring out the input file dimensions.

n1 = dims(1);           % trace length
n2 = prod(dims(2:end)); % number of traces
The first dimension is the trace length, the product of all other dimensions correspond to the number of traces.

trace = 1:n1;           % allocate trace
rsf_create(out,in)      % create an output file
Next, we allocate the trace array and create an output file.

for i2 = 1:n2           % loop over traces
    rsf_read(trace,in,'same');
    trace(trace >   clip) =  clip;
    trace(trace < - clip) = -clip;
    rsf_write(trace,out,'same');
end
Finally, we do the actual work: loop over input traces, reading, clipping, and writing out each trace.



Subsections
next up previous [pdf]

Next: Compiling Up: Fomel: RSF API Previous: Compiling

2013-04-08