How to create a function in matlab

2 Ansichten (letzte 30 Tage)
Abirami
Abirami am 9 Jan. 2015
Bearbeitet: Abirami am 9 Jan. 2015
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 Kommentare
Stephen23
Stephen23 am 9 Jan. 2015
Note you should use not name your variables using i or j, as these are the names of the inbuilt imaginary unit .
Abirami
Abirami am 9 Jan. 2015
oh okay sir...Thank you..i will change it..

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Stalin Samuel
Stalin Samuel am 9 Jan. 2015
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 Kommentar
Stephen23
Stephen23 am 9 Jan. 2015
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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by