Shifting signals to the right

조회 수: 42 (최근 30일)
Curious Mind
Curious Mind 2020년 6월 18일
댓글: Adam Danz 2020년 6월 19일
Hi, I have a matrix, M which is 10*2000 double (10 rows of signals and each signal contains 2000 variables). I want to shift each of the signal in this matrix to the right by say 1. I have a code (below) that can shift a single signal (that is if M contains a single signal, 1*2000). How do I modify this to shift each signal in M at the same time?
The code code for shifting a single signal is:
p = M;
Shift = 1;
Shifted_M = circshift(p,Shift);
In summary, I want a code that can shift each independent row signal in a matrix and output the shifted matrix as Shifted_M. After that I would like to plot this shifted matrix with the original data to visualize it.
Thanks
  댓글 수: 1
Tanveer ul haq
Tanveer ul haq 2020년 6월 18일
% consider your matrix is M then:
M=[1 2 3; 4 5 6; 7 8 9];
Shift = 1;
Shifted_M = circshift(M',Shift);
rotated_matrix = Shifted_M'

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

채택된 답변

Adam Danz
Adam Danz 2020년 6월 18일
If you'd like to circularly shift the data "A" by "K" positions along the "dim" dimension,
Y = circshift(A,K,dim) (click for more info)
So, you'll need to specify the dimension.
  댓글 수: 10
Curious Mind
Curious Mind 2020년 6월 19일
You are correct! I was adding the 1 to the wrong thing. It works now. Also I figured out the plot part. I appreciate your patience and help! Thank you.
Adam Danz
Adam Danz 2020년 6월 19일
Ah, good! Sometimes describing the problem is more difficult than finding the solution. Glad it all worked out!

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by