Trying to create a function of the logistic map xn+1=mu*xn*(1-xn) to calculate and output N+1 states, but I keep getting the error 'Undefined function or variable 'mu'' after using mu as an input argument to the function. Anyone know how to fix this?
function output= logistic_map(mu,x0)
N=20; % the number of states to be generated after the initial state
% Error check
if mu > 4 || mu < 0
error('mu parameter must lie in the range 0 to 4 ')
return % forcing an early return
end
x=x0;
output= zeros(1, N+1); % Storage matrix of N+1 numbers
output(1,1)=x; % The first value in the matrix is initialised to the first value of x
for count = 1:N
x=mu*x*(1-x);
output(1,count+1)=x;
end
end

 採用された回答

Jan
Jan 2021 年 2 月 2 日

1 投票

How do you call this function? Do you start it by pressing the "Run" button? This does not define the inputs.
Call this function from the command windows or from another script or function with defining the input arguments, e.g.:
output= logistic_map(2, 3)

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeAgriculture についてさらに検索

タグ

質問済み:

Rn
2021 年 2 月 2 日

回答済み:

Jan
2021 年 2 月 2 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by