Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to create indexes operations?

조회 수: 1 (최근 30일)
sc
sc 2018년 5월 9일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi!
I've this function:
for i = 1:length(I)
ydata_low(i,:) = [I_0(i) I_1(i) I_2(i) I_3(i) I_4(i)];
ydata_high(i,:) = [I_5(i) I_6(i) I_7(i) I_8(i)];
end
where 0,1,2,3,4,5,6,7,8 are indexes. I'd like, instead this, to do that ydata_low goes from I_0(i) to I_4(i) and ydata_high goes from I_5(i) to I_b(i), where b is 8. How can I do?
  댓글 수: 1
Dennis
Dennis 2018년 5월 9일
편집: Dennis 2018년 5월 9일
With proper indices! Instead of using several vector I_0 to I_X better add 1 dimension to I.
ydata_low(1:5,:) = I(1:5,:);
ydata_high(1:b-5,:) = I(6:b,:);
I do not know how you populate your Is', but I suggest to do it like
for ii=1:numberofdatasets
I(ii)= %put data in here
end
Stephen Cobeldick also put together a neat post about not naming variables I_0,I_1,I_2... https://de.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by