How to create a function in matlab
7 ビュー (過去 30 日間)
古いコメントを表示
Hello I need to create a function for finding out the intial values of a logistic map. The logistic map is given by
x(ii+1)=mu*x(ii)*[1-x(ii)]
where all the values lie between the (0,1).
Where x(1) and mu can b found out from the following formulas
x(1)=(S+R1+R2) (mod1)
mu= 3.9+ [((S+R2)(mod1))/10]
where
R1=(k1k2..k6)/(2^23)
R2=(k7k8..k12)/(2^23)
S=(k20k19..k13)/100
Where
K=k1k2...k20 is the key that im going to be using.it is a 20 bit key where each bit has to be accessed for generating R1 R2 and S
I'll be doing this four times for a different key each. So i thought of writng a function that gets the key from the user and performs the sequence generation using logistic map. Please help. thanks in advance.
2 件のコメント
Stephen23
2015 年 1 月 9 日
Note you should use not name your variables using i or j, as these are the names of the inbuilt imaginary unit .
回答 (1 件)
Stalin Samuel
2015 年 1 月 9 日
function [x] = logistic(k)
R1=(k1k2..k6)/(2^23)
R2=(k7k8..k12)/(2^23)
S=(k20k19..k13)/100
x(1)=(S+R1+R2) (mod1)
mu= 3.9+ [((S+R2)(mod1))/10]
x(i+1)=mu*x(i)*[1-x(i)]
end
1 件のコメント
Stephen23
2015 年 1 月 9 日
When I run this code I get an error as follows:
>> logistic(3)
??? Error: File: logistic.m Line: 2 Column: 9
Unexpected MATLAB operator.
It appears that this code was not tested, as it contains so many bugs and syntax errors. This is not usable MATLAB code:
- referencing variables before they have been defined (eg k1,k2,k6,.etc)
- using ellipses to indicate a range
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!