Editing
Guide to madagascar API
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==MATLAB interface== The MATLAB clip function is listed below. <syntaxhighlight lang="matlab"> 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 </syntaxhighlight> Let us examine it in detail. <syntaxhighlight lang="matlab"> dims = rsf_dim(in); </syntaxhighlight> We start by figuring out the input file dimensions. <syntaxhighlight lang="matlab"> n1 = dims(1); % trace length n2 = prod(dims(2:end)); % number of traces </syntaxhighlight> The first dimension is the trace length, the product of all other dimensions correspond to the number of traces. <syntaxhighlight lang="matlab"> trace = 1:n1; % allocate trace rsf_create(out,in) % create an output file </syntaxhighlight> Next, we allocate the trace array and create an output file. <syntaxhighlight lang="matlab"> 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 </syntaxhighlight> Finally, we do the actual work: loop over input traces, reading, clipping, and writing out each trace. ===Available functions=== Only some of the functions in the <tt>rsf</tt> library have received a MATLAB interface. These functions are <tt>rsf_par</tt>, <tt>rsf_dim</tt>, <tt>rsf_read</tt>, <tt>rsf_write</tt> and <tt>rsf_create</tt>. All these functions except <tt>rsf_par</tt> have been illustrated in the example above. ===Compiling=== The MATLAB script does not require compilation. Simply make sure that <tt>$RSFROOT/lib</tt> is in <tt>MATLABPATH</tt> and <tt>LD_LIBRARY_PATH</tt>.
Summary:
Please note that all contributions to Madagascar are considered to be released under the GNU Free Documentation License 1.3 or later (see
My wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
English
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Getting Madagascar
download
Installation
GitHub repository
SEGTeX
Introduction
Package overview
Tutorial
Hands-on tour
Reproducible documents
Hall of Fame
User Documentation
List of programs
Common programs
Popular programs
The RSF file format
Reproducibility with SCons
Developer documentation
Adding programs
Contributing programs
API demo: clipping data
API demo: explicit finite differences
Community
Conferences
User mailing list
Developer mailing list
GitHub organization
LinkedIn group
Development blog
Twitter
Slack
Tools
What links here
Related changes
Special pages
Page information