File Exchange

image thumbnail

RDSAC and MKSAC: read and write SAC seismic data file

version (247 KB) by François Beauducel
Imports/plots and exports seismic data file in the IRIS/SAC format.


Updated 11 Aug 2016

GitHub view license on GitHub

Matlab codes to read and write SAC seismic data file

Comments and Ratings (19)

Hongyi Su


alaa alaa

I can't get the function to plot my SAC file. I made a new script and wrote x =rdsac(). This opens a browser window and when I click on the SAC file I want to plot and hit 'Select', I get errors on line 223 and line 92. Has someone encountered similar problem?

Thanks mate


There is a coding error in Line 92, it should read: [H,t0] = readheader(fid,varargin);


It is helpful for me.

Irfan Aufa

Thanks Rall for your feedback. This is a good idea to optimize the memory after importing data. Probably the best thing is to let the user adding himself the double() function, if he wants to make extensive signal processing (which is not compatible with all classes).

Rall Walsh

Thanks for this, definitely a great utility! I really appreciate it.

As it stands, it is extremely memory intensive. Loading in a .sac file that is less than 3 KB balloons up to over 10x original size.

I added an option (inelegantly) to not store the time as a double vector, and prevent the float32's from converting to doubles. I am sure others with moderately large datasets would also appreciate this option.

Rall Walsh

Petr Kolar

Exactly what one expect - thanks.

bold baatar

it is need to me.

Does anybody knows how to make changes in boundary conditions in mFD2D using crewes package. also what is the output for each hidden file in mFD2D. how can i learn?

Is it possible to convert SAC file to acceleration time history file? As a civil engineer, I have no idea what count is.


- mksac: major fix (date problem)
- rdsac: adds description string for enumerated header fields

- new MKSAC function to export SAC file from data.

- output alternative returning data, origin time and header.
- undefined header fields are not returned.

- works with big-endian coded files (automatic byte ordering detection)

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux