SourceForge has been redesigned. Learn more.
Close

[471bfe]: / @mp / colon.m  Maximize  Restore  History

Download this file

26 lines (21 with data), 510 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function out = colon(x, y, z)
if (nargin < 2 || nargin > 3)
help ('colon'); return;
end
if (2 == nargin)
[precision, x, y, z] = getmaxprec (x, y, 1);
nstep = 1 + y(1) - x(1);
else
[precision, x, y, z] = getmaxprec (x, y, z);
nstep = 1 + (y(1) - x(1))/z(1);
end
if (nstep < 1)
out = mp([], precision);
else
out = ones ([1 nstep]); ii = 2;
[out(1), x] = deal (x, x+z);
while (x <= y)
[out(ii), x, ii] = deal (x, x+z, ii+1);
end
end
end