필터 지우기
필터 지우기

How do I plot a 144000 sample sound file with 400 samples in different windows with for loop?

조회 수: 1 (최근 30일)
I have a plot of an audio file with 144000 samples. I want to draw these 144000 sample sound files in 400 separate windows each. Each window will contain 400 instances of it, and I want to interpret it in every 400 windows. Can you help me?
  댓글 수: 2
Jan
Jan 2021년 4월 11일
What does this mean: "Each window will contain 400 instances of it" - what is "it"?
furkan akhan
furkan akhan 2021년 4월 11일
I mean the plot in the screenshot I took is 144000 samples. I want to plot this as 400 samples in separate windows.
sound=structWheeze(2,1).SoundData;
for i=1:200:144000
first=sound(i:i+399);
end
plot(first)
I tried this code but it didn't work

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
Star Strider 2021년 4월 11일
편집: Star Strider 2021년 4월 11일
If ‘y’ is the signal, and you have the Signal Processing Toolbox, use the buffer function:
framelen = 400;
frames = buffer(y, framelen);
The ‘frames’ variable is a (400x360) matrix, and each column is a non-overlapping segment of ‘y’ that is 400 samples in length. It would also be possible to use the reshape function, however buffer is the easier option.
To plot them, simply plot each column.
EDIT —
The loop posted in the Comment would indicate that the plots would have 50% overlap, since the segment indices would be:
1 400
201 600
401 800
601 1000
801 1200
and so to the end of the file. The buffer function can also do that.
  댓글 수: 4
furkan akhan
furkan akhan 2021년 4월 11일
Thanks a lot but i wanna ask you a question again. How can I plot these 400x360 data in separate windows? To examine each sample of 400.
Star Strider
Star Strider 2021년 4월 11일
There are at least two options:
for k = 1:size(frames,2)
figure
plot(frames(:,k)) % Plot Each In Separate Figure
end
or:
for k1 = 1:fix(size(frames,2)/10)
figure
for k2 = 1:10 % 36 Figures With 10 subplot Axes Each
subplot(5,2,k2)
plot(frames(:,k2+10*(k1-1)))
title(sprintf('Column %3d', k2+10*(k1-1)))
end
end
and any number of variations on the subplot version. Experiment to get the result you want.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by