How to combine multiple spectrogram and create a single image in MATLAB

32 Ansichten (letzte 30 Tage)
Hello I hope you are doing well. I have the 3 vectors. I want to create a spectrogram of each vectors first save the spectrogram.
and combine the three vectors to create a single overlap spectrogram and save as image file
How can i do it in MATLAB

Antworten (1)

Walter Roberson
Walter Roberson am 12 Sep. 2022
When you permit spectrogram() to display the result, then it always clears the axes it is drawing in. spectrogram() does not just display the result: the output has active controls.
Because of this, if you let spectrogram() display the output, you cannot merge the results at all easily.
What you can do is ask for outputs from spectrogram(), and use the outputs to draw the results any way that is appropriate for you.
But perhaps I am misunderstanding you. Perhaps what you want to do is something more like
combined_signal = mean([first_signal(:), second_signal(:), third_signal(:)], 2);
This assumes that they are all the same length; if not then you will need to pad the shorter ones first.
  13 Kommentare
Siriki Kone
Siriki Kone am 25 Sep. 2022
Do you mean it would the cause of these errors? because was always n=1 but it doesnt change anything, i get the same errors.
Actually I first add my acc with dimensions (:,13) because i subdivised each data in 13 segments. I estimate then the power spectral density for each of them (PSD_Station=10*log10(acc(:,n)); the problem is that i don't know how to plot these psd as an image with time against frequency, i tried with surf, or imagesc but it didnt work.
any solution would be really helpful!
Walter Roberson
Walter Roberson am 25 Sep. 2022
s_rate=200;
dt=1/s_rate;
n = 1;
nov = length(acc(:,n)); %my acc has the dimensions (262144,1)
section1 = ceil(nov/13); %window my acc data in 13 segments
window1 = hanning(section1); %apply a hanning fenster on it
noverlap1 = ceil(3*section1/4); %75% overlapping
f= [0 100]; %my frequencies go from 0 30-40 Hz so i choose to take max f intervall
[s,f,t,psd] =spectrogram(acc,section1,noverlap1,f,s_rate,'psd');

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by