0

カオスマップを繰り返しながら、小数の精度を正確に制御できるようにしたいと思います。特に、Matlabが次の関数で指定した値 p よりも多くも少なくも使用しないようにしたいと思います。

function out = chaotic_logistic(seed,n,p,varargin)
%Returns a vector containing the seed and n iterations 
%of the logistic map: u*x*(1-x), which is chaotic on the
%unit interval when u is contained in (~3.56995,4)

%If a third argument is passed, this will be used as the u parameter.
%Otherwise u=4 by default.

%Finally, if 'last' is passed as the fourth argument, only the last
%iteration will be returned.

%NOTE: As currently designed, this function can be broken 
%by passing 'last' as the THIRD argument, etc. SO BE CAREFUL OR FIX IT.

digits(p) %sets desried accuracy to p decimal places??

if length(varargin)>=1 %default param 
    param = varargin{1};
else
    param = 4;
end

out = [seed zeros(1,n-1)]; %preallocate

apply_fcn = vpa(seed); %see vpa doc??

for i=1:n-1
    apply_fcn = vpa(param.*apply_fcn.*(1-apply_fcn)); %note vpa again
    out(i+1) = apply_fcn;
end

if length(varargin)==2 && strcmp(varargin{2},'last')
    out = out(end);
end

私が正しく理解していればdigits()、トリックを実行する必要がありますが、よくわかりません。関数を呼び出すときに指定された精度を持っていることが重要です (カオスに詳しい人なら誰でも知っているでしょう!)。

前もって感謝します!

4

0 に答える 0