substituting values into an array

조회 수: 2 (최근 30일)
Morten Jensen
Morten Jensen 2011년 6월 21일
Hi
I need to substitute some values from one arry into another but is getting the error:
??? Subscript indices must either be real positive integers or logicals.
The arrays in question as well as my current attempt are as given below:
K = 130;
T = [0 33 57];
V = [0.9 0 .5];
period = ones(2,K);
period(1,:) = 0:K-1;
for i = 1:size(T,2)
period(2,T(1,i):end) = V(1,i);
end
Can anyone help me with this problem?

채택된 답변

Sean de Wolski
Sean de Wolski 2011년 6월 21일
You can't have period(0), it tries to reference this when
i = 1
period(2,0:end); %substituting T(1)
Start your indexing at one instead. Keep a reference vector (like T) if you need to know what period(x) corresponds to.
  댓글 수: 1
Morten Jensen
Morten Jensen 2011년 6월 21일
of course.. thanks! I must have stared myself blind looking for the error

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by