How to write this in matlab?

조회 수: 4 (최근 30일)
Nazish
Nazish 2019년 7월 28일
댓글: Adam Danz 2020년 6월 18일
How to write this equation in matlab?
f (xn) = x(n+1) = x(n)/a for 0 ≤ x(n) ≤ a
1−x(n)/1−a a ≤ x(n) ≤ 1
Where x0 is the initial value and xn ∈ [0,1]. The control parameter a ∈ (0,1) and when a is not equal to 0.5, system enters a chaotic state.

답변 (1개)

Rik
Rik 2019년 7월 28일
편집: madhan ravi 2019년 7월 29일
Because of the recursion limit (and other factors), it is smarter to implement this in a loop, instead of a recursive function.
The code below has some assumptions about your function you should check, but it shows the general idea.
x0=0.1;
N=30;
a=0.4;
x=zeros(N,1);
x(1)=x0;
for n=1:(N-1)
if 0<=x(n) && x(n)<a
x(n+1)= x(n)/a;
else
x(n+1)= (1-x(n))/(1-a);
end
end
  댓글 수: 5
Rik
Rik 2020년 6월 18일
Eloquently put. What don't you understand about that line?
Adam Danz
Adam Danz 2020년 6월 18일
@Fawrad, X = zeros(sz1,...,szN) check out that link.

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

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by