-1

I need to fill a 360 element matrix with periods of 90 elements for different phiStart and phiExit values:

flute    = 4;
phiStart = 0;
phiExit  = 90;
phiDelta = 1;
phiPitch = 360 / flute;

for g = 0:abs(phiExit - phiStart);
    for k = 0:abs(phiExit - phiStart);
        for j = 0:abs(phiExit - phiStart);
            for m = 0:abs(phiExit - phiStart);
                for i = 0:abs(phiExit - phiStart);
                    answerA = phiStart + i * phiDelta;
                    phi(i+1) = answerA;
                end
                answerA = phiStart + m * phiDelta;
                phi(m + phiPitch) = answerA;
            end
            answerA = phiStart + j * phiDelta;
            phi(j + 2 * phiPitch) = answerA;
        end
        answerA = phiStart + k * phiDelta;
        phi(k + 3 * phiPitch) = answerA;
    end
    answerA = phiStart + g * phiDelta;
    phi(g + 4 * phiPitch) = answerA;
end

b = (phi > 0);  % dummy matrix for edge cofficients
h = feedRate * sin(phi / 180 * pi);
ysap
  • 7,723
  • 7
  • 59
  • 122
  • 4
    What language is this? (Matlab?) – ysap Apr 09 '17 at 23:11
  • 1
    'phiStart' and 'phiDelta' are constants. Why do you need the nesting loops? Are any 'phi' values being overwritten again and again? – ysap Apr 09 '17 at 23:33
  • Yes phiStart and phiExit are constants defined by me. I need to fill a matrix like this. lets say a row matrix with 15 members. phiStart=2 phiExit=4 and the period is 5 -----> Thus matrix should be [2 3 4 0 0 2 3 4 0 0 2 3 4 0 0] I need to solve that in simpliest way for a matrix with 360 members The language is matlab. Thank you for your help – Oğuz Mutlu Apr 10 '17 at 20:22

1 Answers1

0

Sorry if this makes no sense (just trying to help), I don't even know in what language it is written, but what I read in the original code points to something like

for i = 0:abs(phiExit - phiStart);
    answerA = phiStart + i * phiDelta;
    for j = 0:abs(flute - 1)
        phi(i + j * phiPitch) = answerA;
    end
end
MC ND
  • 69,615
  • 8
  • 84
  • 126