MATLAB: For loop adding numbers on left side of equal sign

endfminconfor loophelpiterationiterationslinprogloopnormal distributionpdfwhile loop

Hi, I want to make a for loop which iterates the the values of my prob function. Ideally I want to the loop to do for [89-105] to give the sequence of pk(89)=prob(89) & pk(90)=prob(90) and so on. I already have the loop working that it gives the values of prob(k) in the correct sequence. However, I am unable to have the loop adding the values of i to be 89,90,91,92 and so. It must be a simple command but I cannot find it. Hope some can help me out.
pd= makedist('normal','mu',100,'sigma',10)
demand = [0:1:200];
prob = normpdf(demand,100,10);
for k=89:1:105;
Furthermore, the error that I get running the code regarding the line pki)=prob(k) is [Subscript indices must either be real positive integers or logicals.]

Best Answer

  • for k=89:1:105;
    Yes, you can get it pk(89) to pk(105)
    but what about pk(1), pk(2),...might be zero. yes?