array manipulation - a few basic questions

조회 수: 4 (최근 30일)
Tom
Tom 2012년 3월 18일
Hi, I have to do a bit of array manipulation and I really don't have a clue about it.
First I need to know how to take a double array, and turn it in to a 2046x1 array (twice as long), with 1024-2046 just being exactly the same as 1-1023.
Then I need to know how to chop off the first half of an array, in this case taking a 2046x1 array and disregarding the first 1-1023, leaving only a 1023x1 array made up from only the second half of the 2046x1 array.
I know it's simple stuff, but I just haven't done it before.
  댓글 수: 1
Matt Fig
Matt Fig 2012년 11월 2일
Tom's question
Hi, I have to do a bit of array manipulation and I really don't have a clue about it.
First I need to know how to take a double array, and turn it in to a 2046x1 array (twice as long), with 1024-2046 just being exactly the same as 1-1023.
Then I need to know how to chop off the first half of an array, in this case taking a 2046x1 array and disregarding the first 1-1023, leaving only a 1023x1 array made up from only the second half of the 2046x1 array.
I know it's simple stuff, but I just haven't done it before.

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

채택된 답변

Rick Rosson
Rick Rosson 2012년 3월 19일
Please try:
x = rand(1023,1);
y = repmat(x,2,1);
z = y(1024:2046);
HTH.
Rick
  댓글 수: 6
Tom
Tom 2012년 3월 19일
I guessed that z = y(numel(x)+1:numel(y)); would work too. That make sense?
Rick Rosson
Rick Rosson 2012년 3월 19일
Yes, at least in this particular case, but not generally.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by