Graphics in While loop

While[xop[[i]] > xq,
xop = Append[xop, yop[[i]]/([Alpha]m + (1 - [Alpha]m)*yop[[i]])];
yop = Append[yop, R/(R + 1)*xop[[i + 1]] + xd/(R + 1)];
pv[[i]] =
Graphics[
Line[{{xop[[i + 1]], yop[[i]]}, {xop[[i + 1]], yop[[i + 1]]}}]];
ph[[i]] =
Graphics[Line[{{xop[[i]], yop[[i]]}, {xop[[i + 1]], yop[[i]]}}]];
n = i; i++];

Hello, I’m creating a function for McCabe-Thiel method. I want to use Graphics in While loop to store plots in list. But I can’t save it on the list. I’d like to know if there is another way. (English may be a little awkward because I am not from America.)

To give you an easier example:

pr = {}; i = 1; While[i > 4, 
 pr = AppendTo[pr, Graphics[Line[{{i, i}, {i + 1, i + 1}}]]]]

result : pr={}

Why???

You have i initialized to 1. The loop condition is while i > 4. I don’t believe it will execute.

Also, if you know in advance how many graphics you will create, then use Table to initialize your array and simply make assignments instead of the more costly Append.

pr = Table[{}, numberOfGraphs];
While[ ...
    pr[[k]] = ...

Thank you very much for your reply. I cannot specify the number of graphics to generate. but I’ll try based on what you said

Thanks to your help, I made the code I wanted. Thank you very much.

MT method.nb (22.2 KB)