plotting graphs after for loop

1 view (last 30 days)
Kareem AlBokhari
Kareem AlBokhari on 28 Sep 2015
Answered: Walter Roberson on 28 Sep 2015
I have a code with iterations and I want to make a graph for each iteration of 2 for loops and all appear in on graph figure ex
cvals = 1200:100:1600;
bvals = 5:1:20;
PR=[];
for cidx = 1 : length(cvals)
c = cvals(cidx);
for bidx = 1 : length(bvals)
b = bvals(bidx);
....... eqns
result{cidx}(bidx) = wnet/qina ;
I wrote this code
plot(PR, result {1,1},'-o', PR, result {1,2},'-o', ...
PR, result {1,3},'-o', PR, result {1,4},'-o', ...
PR , result {1,5},'-o')
but if the range of the of the cvals increased , the rest of the graphs wont be shown , ex 1200:100:2000 from 1700 till 2000 the graphs wont be shown until I add them in the plot command
any help
  1 Comment
Adam
Adam on 28 Sep 2015
At what point are the cvals increasing in range? You mean the code above stops at 1600 even when you put 2000 as the maximum or that after calculating upto 1600 you then make a change to extend to 2000 and then you have to plot these extra results manually?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 28 Sep 2015
numc = length(cvals);
augmented_result = [repmat({PR}, 1, numc); result; repmat({'-o'}, 1, numc)];
plot(augmented_result{:});

Categories

Find more on Graphics Object Properties 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!