# skip the value in for-loop

1 view (last 30 days)
Kapil Gupta on 5 Apr 2020
Edited: dpb on 6 Apr 2020
a = 27;
c = 11;
m = 54;
x(1)=2;
for i=2:25
x(i) = (mod(a * x(i-1)+c ,m))
end
here i want to skip the first value x(1)=2 to print in each iteration.
so please guide me how can i skip this value in output.

David Hill on 5 Apr 2020
a = 27;
c = 11;
m = 54;
x(1)=2;
for i=2:25
x(i) = (mod(a * x(i-1)+c ,m))
end
x(2:end)

David Hill on 5 Apr 2020
I don't understand what you are saying. Please explain more. What do you want your output to be?
Kapil Gupta on 5 Apr 2020
i want to skip first element from each output after each iteration.and follow the loop with if condition and print a single output for x(i) and R(i).now i think you may understand my problem.
David Hill on 5 Apr 2020
Show me what you want for your output (i=2:4)

dpb on 5 Apr 2020
Edited: dpb on 6 Apr 2020
AMENDED:
Probably simplest is just
a = 27;
c = 11;
m = 54;
x(1)=2;
for i=2:25
x(i) = (mod(a * x(i-1)+c ,m));
end
x=x(2:end);
maybe? Just guessing; we can't tell what it is that you really want, unfortunately.

Kapil Gupta on 5 Apr 2020