How to shift the graph?
2 views (last 30 days)
Show older comments
y=audioread('speech.wav');
subplot(2,3,1);
plot(y);
xlabel('Samples');
ylabel('Magnitude');
title('Original speech signal');
%Dividing the signal into frames
f_duration = 0.025;
fs=8000;
f_size = (f_duration.*fs);
n = length(y);
n_f = floor(n/f_size); %no. of frames
temp = 0;
for i = 1 : n_f
frames(i,:) = y(temp + 1 : temp + f_size);
temp = temp + f_size;
end
Now I want to plot only frame 1 and frame 2 in such a way that when frame 1 ends after that only frame 2 starts. For this I need to shift the x-axis by f_size. But i am unable to do so.
Please help me.
0 Comments
Answers (2)
Star Strider
on 27 Jun 2022
t = linspace(0, 250, 5000);
s = exp(-0.01*t) .* sin(2*pi*t*700);
figure
plot(t, s)
xlabel('Time')
ylabel('Amplitude')
title ('Original Signal')
Tbuf = buffer(t, 500);
Sbuf = buffer(s, 500);
NrSubplots = size(Tbuf,2);
spcol = 2;
sprow = floor(NrSubplots/spcol);
ylimv = [min(s) max(s)];
for k = 1:NrSubplots
subplot(sprow,spcol,k)
plot(Tbuf(:,k), Sbuf(:,k))
grid
xlim([min(Tbuf(:,k)), max(Tbuf(:,k))])
ylim(ylimv*1.1)
xlabel('Time')
ylabel('Amplitude')
title(sprintf('Segment #%2d: t = %.2f to %.2f', k, min(Tbuf(:,k)), max(Tbuf(:,k))))
end
.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!