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