I want to plot my results individually under each other like a row and not a continues impulse response . Something isn't correct when i try it, Can someone help please?

조회 수: 7 (최근 30일)
x = zeros(1, 20000);
x(1 : 4000 : 20000);
xresh = reshapex, 4000, 5);
So every 4000fs i want to plotted graph?

채택된 답변

Star Strider
Star Strider 2019년 1월 18일
I am not certain what you want.
Try this:
x = linspace(0, 20000, 20000)'; % Create Column Vector
y = sin(x*pi/500); % Create Data
xresh = reshape(x, 4000, 5);
yresh = reshape(y, 4000, 5);
yresh = bsxfun(@plus, yresh, (0:2:2*(size(yresh,2)-1))); % Add Offsets
figure
plot(xresh, yresh)
grid
Experiment to get your desired result.
  댓글 수: 9
codefanta
codefanta 2019년 1월 22일
Thank you so much it all make sense.
one last question, if i want to change the recording time do i need to change my reshapes ?
Star Strider
Star Strider 2019년 1월 22일
As always, my pleasure.
Yes. You can probably make that dynamic by doing something like:
xresh = reshape(x, fix(x/5), 5);
However, you need to choose a recording tiime and sampling frequency that will produce a value for the length of your recorded sound vector that is an integer multiple of the number of segments you want. The reshape function will fail otherwise.

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

추가 답변 (2개)

codefanta
codefanta 2019년 1월 23일
yresh = bsxfun ( @plus , yresh, ( 0 : 2 : 2*(size (yresh,2) -1)));
set (gca, 'ytick', (0 : 2 : 2*( size( yresh,2) -1) , 'yticklabel', (1:5))
Would you be able to explain this 2 bits of code from your code as I dont 100% understand what they do?
Thanks
  댓글 수: 9

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


codefanta
codefanta 2019년 1월 23일
hello
is it not possible to get my frequency domain and have my results plotted one under each other like figure 1 and 2 before the new code?
  댓글 수: 3
codefanta
codefanta 2019년 1월 27일
편집: codefanta 2019년 1월 27일
Hello
Sorry I didnt reply to your last comment, It was very helpful though!
I was hoping you could talk me through how this funcion works:
"yresh = bsxfun(@plus, yresh, ( 0 : size(yresh,2 ) -1) ) * 2 ); "
So what does the (yresh, 2), the -1 and the *2 do in the function?
thanks
Star Strider
Star Strider 2019년 1월 27일
As always, my pleasure.
That bsxfun (link) call multiplies each column of ‘yresh’ by the corresponding element of the ‘( 0 : size(yresh,2 ) -1) ) * 2’ vector. That vector is equivalent to ‘[0, 2, 4, 6, 8]’. The purpose is to separate the columns by multiples of 2. Since the sound vectors are limited to a magnitude of ±1, this guarantees that they will be separated, and not overlap in the plot.

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

카테고리

Help CenterFile Exchange에서 Frequency Transformations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by