필터 지우기
필터 지우기

Copy numbers vector to vector

조회 수: 6 (최근 30일)
klipya
klipya 2012년 8월 3일
Hello! If I have a vector and I need to copy some numbers from another vector how can I do it?
For example, this is what I've done:
graph1= zeros(1:100)
i1=50
i2=55
I(i1:i2)=v1(240:245)
v1= v1 is another vector and I want to copy in the 'graph1' (on the positions 50 to 51), the numbers of the vector v1 in the position 240:245.
thanks a lot,

채택된 답변

Daniel Shub
Daniel Shub 2012년 8월 3일
편집: Daniel Shub 2012년 8월 3일
You need to read the documentation. This is really a simple problem and your code is close.
v1 = randn(1, 255); % We need this in order to do the copy
graph1= zeros(1, 100); % Note this is not 1:100
i1=50;
i2=55;
graph1(i1:i2)=v1(240:245); % Your code had I, which you never describe.
  댓글 수: 1
klipya
klipya 2012년 8월 6일
Thanks Daniel, now it works!

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

추가 답변 (1개)

venkat vasu
venkat vasu 2012년 8월 3일
graph1(50:0.2:51)=v1(240:245);
  댓글 수: 3
venkat vasu
venkat vasu 2012년 8월 3일
i think you want to insert from 240-245th position vector in b/w 50-51 position. so in b/w 50-51 like that only we can insert the vector.
Walter Roberson
Walter Roberson 2012년 8월 10일
It is not possible to use non-integral subscripts for a vector, so this code will not work.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by