for loop indexing and skip numbers
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Damith
am 28 Mai 2014
Kommentiert: Abraxas
am 25 Apr. 2019
Hi,
I need to include for loop in MATLAB to start with 2:13. But I need to start with 2,3,4 and skip 5 and again 6,7,8 and skip 9 and 10,11,12 until 13.
How can I implement this is for loop?
Many thanks in advance.
0 Kommentare
Akzeptierte Antwort
Roger Stafford
am 28 Mai 2014
You can also use
ix = floor((4*(1:n)+2)/3);
where n is the desired length of the output.
Weitere Antworten (3)
the cyclist
am 28 Mai 2014
Yet another method:
idx = bsxfun(@plus,[1 2 3]',1:4:100)
for ii = idx(:)
disp(ii)
end
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!