Info
此问题已关闭。 请重新打开它进行编辑或回答。
How to create indexes operations?
1 次查看(过去 30 天)
显示 更早的评论
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
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!