Stacking of of power spectrum

I have computed power spectrum of number of time series of various stations. Can I stack the spectra to one power spectrum plot?
I have simply took all the spectra, and plotted but I need a single line spectra? Is there any code? Any lead will be very helpful.

4 Comments

Hi, this is rather a physical question than MATLAB issue, but let's try. What do you mean exactly by power spectra? Is it a power spectral density as discussed here: https://en.wikipedia.org/wiki/Spectral_density ?
Yes it is power spectral density
I am trying to do it in matlab that is why it is matlab issue
hi
If I understand right , you simply want the mean of all your spectra ?

Sign in to comment.

Answers (1)

I understand that you wish to stack the power spectra plots into a single "stacked" plot in MATLAB.
To display different line spectra on the same plot, you can use "hold on" and "hold off" command in MATLAB to persist plot outputs and superimpose multiple plots together in order to get one combined plot. Refer to the following documentation for "hold":
For example:
load indoors.mat
load outdoors.mat
hold on
plot(indoors.Humidity)
plot(outdoors.Humidity)
hold off
As a 2nd workaround, you can refer to the "stackedplot()" method documentation in MATLAB, which stacks different plots onto a single plot with the common variable axis:
You can use the following MATLAB command to obtain the same output as above:
stackedplot(indoors,outdoors,"Humidity")
Hope this helps!

Categories

Find more on MATLAB in Help Center and File Exchange

Asked:

on 19 Jan 2023

Answered:

on 3 Feb 2023

Community Treasure Hunt

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

Start Hunting!