필터 지우기
필터 지우기

Array question

조회 수: 1 (최근 30일)
Susan
Susan 2011년 7월 26일
Hey every1,
I am trying to shift content of one array starting from i = 2; a[i] = b[i-d)
so I created for loop.. for i = 2:10 a[i]= b[i-d].. Its actually putting the content there starting from index 2 so I wanted when I plot it to discard a[1] and just start from a[2]. In matlab workspace the content is correct so my for loop is right but a[1] is still there and I want to shift to just be discarded ???
Thanks in advance

채택된 답변

Oleg Komarov
Oleg Komarov 2011년 7월 26일
idx = 2:10
a = b(i-d);
  댓글 수: 2
Susan
Susan 2011년 7월 26일
a should be an array .. Ok probably I didn't explain what I am looking for probably.. I know how to write the for loop.. which is similar to this for i=2:10
a(i-1) = b(i-d)
end
but my question is when I want to plot my two arrays I want a to start from 2 and discard 1 even though I already have value to one, Is there a way to discard the first index in the array??
Oleg Komarov
Oleg Komarov 2011년 7월 26일
When you say discard I understand:
a(1) = []; % or equivalently a = a(2:end);
If you want to to preserve the size of a keeping a(1) but you want to miss the point in the plot you can put a NaN there:
a(1) = NaN;

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

추가 답변 (1개)

the cyclist
the cyclist 2011년 7월 26일
It is not perfectly clear to me what you want, but maybe something like this?
for i=2:10
a(i-1) = b(i-d)
% ...
end
  댓글 수: 1
Susan
Susan 2011년 7월 26일
Yeah I did it that way but because the array I already created it with some data not I want to move the b content to a which I did but I want when I am plotting it to discard a[1] and just start from a[2]

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by