subplot automatically fill in next position for selection of plots in for loop
Ältere Kommentare anzeigen
I have a state variable that ranges from 1:20 but I only want to plot 4:11 in a 2x4 grid.
I'm trying to use the subplot function, but I can't figure out how to make the plots show up in the position I want them to.
Essential what I have is
state = 4;
subplot(2,4,1)
for state = 5:11;
subplot(2,4,state)
end
but when I have the position for states 5:11 as "state" it offsets them as if those other states I'm not selecting were there, and I end up with this

is there a way to have the 5:11 plots just fill in the next position without having to write them out one at a time? I've tried [2:8] and that didn't work.
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 26 Nov. 2025
subplot(2,4,state-4)
Kategorien
Mehr zu Subplots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!