필터 지우기
필터 지우기

How to create a function in matlab

조회 수: 3 (최근 30일)
Abirami
Abirami 2015년 1월 9일
편집: Abirami 2015년 1월 9일
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
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 .
Abirami
Abirami 2015년 1월 9일
oh okay sir...Thank you..i will change it..

댓글을 달려면 로그인하십시오.

답변 (1개)

Stalin Samuel
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
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 CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by