File Exchange

image thumbnail

Spectral acceleration, velocity and displacement spectra

version (104 KB) by Dr. Erol Kalkan, P.E.
This is a MatLAB function to compute linear-elastic damped response spectrum of time series


Updated 12 Oct 2019

View Version History

View License

The function generates pseudo-spectral acceleration (PSA), pseudo-spectral velocity (PSV) and spectral displacement (SD) spectra for given damping ratio (e.g., 5% of critical). Spectral ordinates are for linear-elastic single-degree-of-freedom system with unit mass. A clear example is provided in demo.m file in zipped folder. Also provided is a plotting function for PSA, PSV and SD spectra.

Cite As

Dr. Erol Kalkan, P.E. (2021). Spectral acceleration, velocity and displacement spectra (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (26)

Farbod Yarmohammadi

Thanks for the code. Worked perfectly.

Usman Siddique

Hi can you please explain these lines.
vel = cumtrapz(gacc)*dt;
disp = cumtrapz(vel)*dt;
and also these
y(:,1) = [0;0];
A = [0 1; -K -C]; Ae = expm(A*dt); AeB = A\(Ae-eye(2))*[0;1];

for k = 2:numel(gacc)
y(:,k) = Ae*y(:,k-1) + AeB*gacc(k);

what does it mean, is it one of the method to solve EOM like Newmark etc?

Caglar Kizilpinar

sir Dr kalkan. it is giving me errors.

Not enough input arguments.

Error in responseSpectra (line 68)
vel = cumtrapz(gacc)*dt;

Douglas Anderson

Very nice. How difficult is it to convert to frequency rather than period (for higher frequency signals, lower rise structures)? Any suggestions?
Thank you.

Dr. Erol Kalkan, P.E.

I replaced the subplot1 routine in the new version. Apparently, the older one had a bug. I have tested the new code using MatLAB 2018, and it is plotting correctly.

Margaret Glasgow

Same Error as Salman had. Using R2018a.

Error using matlab.ui.Figure/set
Handles of type Legend cannot be made the current Axes.

Error in subplot1 (line 133)

Error in plotSpectra (line 21)
subplot1(2); hold;

Error in demo (line 26)

Ronak Jhaveri

Volkan Sevilgen


Please review the code for very short periods (or large frequencies) i.e.<0.05 sec there are discrepancies when compared to solutions using the Newmark method, or when compared with software as seismosignal.

Dr. Erol Kalkan, P.E.

It shouldn't give any such errors; what version of MatLAB are you using?

Error using matlab.ui.Figure/set
Handles of type Legend cannot be made the current Axes.

Error in subplot1 (line 133)

Error in plotSpectra (line 21)
subplot1(2); hold;

Dr. Erol Kalkan, P.E.

It uses time-domain solution to solve the second-order differential equation of motion.

Hamdullah Livaoglu

thanks mr kalkan, a fast algorithm to estimate the spectral accrelation, you mentioned spectral solititon in the code, i wonder is it a SDOF frequnecy domain method or a numerical integration time domain method?


Thans Dr. Erol

Dr. Erol Kalkan, P.E.

The code has the proper citation to a solver used.

jim junker

This file is copied from a Caltech report. Plagiarism!

Pierluigi Fumi

Thanks a lot for your prompt answer Dr Kalkan!

That's correct. For example, xi = 0.05 for 5% of critical damping.

Pierluigi Fumi

Hello Dr. Kalkan, just a question on the parameter xi (mentioned as "critical damping" in your comment): is this the fraction with respect to the critical damping ? i.e. 0.01 = 1% of critical damping (zero overshoot) ?

Thanks a lot for your useful function and Best Regards.

Dr. Erol Kalkan, P.E.

If you call the function as [PSA, PSV, SD] = responseSpectra(xi, sPeriod, gacc, dt), It will produce PSA, PSV and SD as separate arrays.

Dr. Erol Kalkan, P.E.

Thanks Mimo, I will make the changes per your suggestion. I do have MatLAB code to generate inelastic spectrum as well. I will post that one as well.


Thanks for this code Dr Kalkan. I am just curios if you have also developed any code for inelastic response?
Also the current code prints the ans (which is PSA) after running the it doesn't crate any vector for plotting. Is it possible for you to modify it to produce PSA, PSV and SD vectors separately?

First time, I haven't seen this error. The function has been fully tested in MatLAB version 2013a. Were you able to generate get the results? If you e-mail me your input waveform, I can check it.


Thanks for the function. I receive the following warning though:
Warning: Matrix is singular to working precision

Have you seen this before?

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

Inspired by: An improved subplot function

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!