How to write this in matlab?
Mostrar comentarios más antiguos
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.
Respuestas (1)
Rik
el 28 de Jul. de 2019
Editada: madhan ravi
el 29 de Jul. de 2019
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 comentarios
darova
el 29 de Jul. de 2019
Please use tabs to maek your code more readable
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
Rik
el 29 de Jul. de 2019
I'm on mobile so formatting is very annoying and time consuming.
If anyone with editing privileges sees this, feel free to edit. Otherwise I might fix it in a few days.
Fawad Masood
el 18 de Jun. de 2020
x=zeros(N,1);??????????????????????????????
Rik
el 18 de Jun. de 2020
Eloquently put. What don't you understand about that line?
Adam Danz
el 18 de Jun. de 2020
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!