Effacer les filtres
Effacer les filtres

How to create a function in matlab

2 vues (au cours des 30 derniers jours)
Abirami
Abirami le 9 Jan 2015
Modifié(e) : Abirami le 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 commentaires
Stephen23
Stephen23 le 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 le 9 Jan 2015
oh okay sir...Thank you..i will change it..

Connectez-vous pour commenter.

Réponses (1)

Stalin Samuel
Stalin Samuel le 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 commentaire
Stephen23
Stephen23 le 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

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by