hi, if i have array=[89 130 150 180...],in 1st iteration i need to perform "1:array(1)",in 2nd iteration i need "array(1)+1 :array(2)",in 3rd iteration i need "array(2)+1 :array(3)" and so on,i tried a lot,plz help me
1 次查看(过去 30 天)
显示 更早的评论
help plz
采纳的回答
Walter Roberson
2015-9-30
编辑:Walter Roberson
2015-10-2
array=[89 130 150 180...]
tarray = [1 array];
for K = 1 : length(tarray)-1
tarray(K):tarray(K+1)
end
2 个评论
Walter Roberson
2015-10-2
array=[89 130 150 180...]
tarray = [0 array];
for K = 1 : length(tarray)-1
tarray(K)+1:tarray(K+1)
end
更多回答(1 个)
Julia
2015-9-30
Hi,
my suggestion is:
do the first iteration outside the loop, the remaining can be done within:
1:array(1);
% do s.th.
for i=1:size(array)-1
(array(i)+1) : array(i+1);
% do s.th.
end
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!