leaving one out help
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
cgo
am 3 Dez. 2018
Beantwortet: Jos (10584)
am 3 Dez. 2018
I want to make a loop for a vector s = [1:10], but for each round I want to leave one element.
So for the first round, s = [1:9] only, then s = [2:10], then s = [1, 3:10], s = [1,2,4:10], etc.
How do I do this?
thanks
0 Kommentare
Akzeptierte Antwort
Jos (10584)
am 3 Dez. 2018
% One of the many ways ...
N = 10 ;
for k = 1:N
s = [1:k-1 k+1:N]
% your code using s
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements 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!