annotate sequences/expdata.m @ 2:7357e1dc2ad6
Simplified scheduler library with new schedule representation.
author |
samer |
date |
Sat, 22 Dec 2012 16:17:51 +0000 |
parents |
672052bd81f8 |
children |
3f77126f7b5f |
rev |
line source |
samer@0
|
1 function y=expdata(A,B,N,M)
|
samer@0
|
2 % expdata - exponential data sequence
|
samer@0
|
3 %
|
samer@0
|
4 % expdata ::
|
samer@0
|
5 % real ~'initial value',
|
samer@0
|
6 % real ~'final value',
|
samer@0
|
7 % natural ~'number of steps (sequence length is steps+1),
|
samer@0
|
8 % M:natural ~'buffer size'
|
samer@0
|
9 % -> seq [[1,M]].
|
samer@0
|
10
|
samer@0
|
11 if nargin<4, M=1; end
|
samer@0
|
12
|
samer@0
|
13 lA=log(A);
|
samer@0
|
14 k=(log(B)-lA)/N;
|
samer@0
|
15 y=unfold(@ls1,0:M-1);
|
samer@0
|
16 %y=windowdata(linspace(A,B,N),M,M);
|
samer@0
|
17
|
samer@0
|
18 function [X,I]=ls1(I),
|
samer@0
|
19 surp=I(end)-N;
|
samer@0
|
20 if surp>=0,
|
samer@0
|
21 X=exp(lA+k*I(1:end-surp));
|
samer@0
|
22 if surp<M, X(end)=B; end
|
samer@0
|
23 else
|
samer@0
|
24 X=exp(lA+k*I);
|
samer@0
|
25 end
|
samer@0
|
26 I=I+M;
|
samer@0
|
27 end
|
samer@0
|
28
|
samer@0
|
29 end
|
samer@0
|
30
|