How can I change the colorbar limits/scale of a spectrogram?
121 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sebastian Vazquez
le 19 Juil 2021
Commenté : Sebastian Vazquez
le 19 Juil 2021
Hello, I would like to change the limits of the colorbar for a spectrogram so that all my plots have an identical scale. Here is the code I am using:
clc; close all; clear variables;
trial1 = 'No_water_charge.wav';
[y1,Fs1] = audioread(trial1); %Reading the wav file
t1 = 0:1.00002/Fs1:length(y1)/Fs1; %Calculating the time
newFs1 = 3000; %New sampling frequency
[P1,Q1] = rat(newFs1/Fs1); %Assigning ratio values to new Fs
newy1 = resample(y1,P1,Q1); %Resampling the data
newt1 = 0:1.000002/newFs1:length(newy1)/newFs1; %Creating a new time
figure
spectrogram(newy1,256,250,[],newFs1,'yaxis','psd');%Generating the spectrogram
title('No water charge')
h1 = gca;
h1.XTickLabel = string(h1.XTick*60);
xlabel('Time (s)');
trial2 = 'No_water_discharge.wav';
[y2,Fs2] = audioread(trial2);
t2 = 0:1.00002/Fs2:length(y2)/Fs2;
newFs2 = 3000;
[P2,Q2] = rat(newFs2/Fs2);
newy2 = resample(y2,P2,Q2);
newt2 = 0:1.000002/newFs2:length(newy2)/newFs2;
figure
spectrogram(newy2,256,250,[],newFs2,'yaxis','psd')
title('No water discharge')
h2 = gca;
h2.XTickLabel = string(h2.XTick*60);
xlabel('Time (s)');
This code produces the following plots:
If possible, I would like their colorbar scales to be the same so instead of one maxing out at 80 and the other at 90, I would like them both to be at 80 if possible. Thank you for your time.
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Blue dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!