Multiple plots in a for loop combined with variable cell arrays
Show older comments
Okay so i think my title sounds more difficult then it actually is.
So as a basic example: I have 2 Sets of Data, lets say y=x and y=2x, both range from 0 to 10. I want to plot both of them but i specificly want to look at x between 2 and 6. As i sometimes have more datasets all of this is in a for loop.
I Split each set of data into 3 pieces. 1. irrelevant range 0-2
2. relevant range 2-6
3. irrelevant range 6-10
All of this worked BUT now my problem: I try to plot them inside the loop like u see below with i beeing my loop index. But no matter the order there is always the second dataset of the first to plots missing. In the example below x_irrelevant2{2} and x_relevant{2} are missing and i dont know why.
plot(x_irrelevant2{i},y_irrelevant2{i},'color',[0.5 0.5 0.5],'Marker','.','linestyle','none')
plot(x_relevant{i},y_relevant{i},'color',c{i},'Marker','.','linestyle','none')
plot(x_irrelevant1{i},y_irrelevant1{i},'color',[0.5 0.5 0.5],'Marker','.','linestyle','none')
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!