How to align the power plot correctly?
Mostra commenti meno recenti
I am calculating power of signal for each second and then plotting it on the power plot graph. What I want: For example the power of signal between 0th and 1st second should be plotted on "1" of x-axis of power plot.
What I have: The plot is off by 1 unit. The power calculated for 0-1 sec is shown on "0" instead of "1". How can I align it with the power calculations?*
*I need my both graphs to start from 0. I want the axis of both the plots to be on the same line as shown in graph.
If you see the figure attached, the power of signal between 4th and 5th second is shown at "4" on x axis, instead it should be shown on "5" in power plot.

I have this code:
[y,fs]=audioread('Untitled_40.wav');
y_b=bandpass(y,[300 2000],fs);
N=length(y);
time=N/fs;
t = linspace(0, time, N);
subplot(2,1,1);
plot (t,y_b);
xlim([0 time])
ylim([-0.5 0.5])
xticks([1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21]);
yticks([-0.5 -0.25 0 0.25 0.5])
grid on;
xlabel('Time');
ylabel('Amplitude');
title('Raw data');
y_seg=buffer(y_b,fs);
y_p=rms(y_seg.^2); %Edited the formula of power on 7/26/2021
x=(0:time);
subplot (2,1,2);
plot(x,y_p);
xlim([0 time])
xticks([1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21]);
grid on;
grid minor;
xlabel('Time');
ylabel('Power');
title('Power plot');
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Multirate Signal Processing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
