Find first row where the first 10 elements of that row are unique from each other
4 次查看(过去 30 天)
显示 更早的评论
Hi,
I am plotting the Ricker map and trying to find at what point chaos in the map occurs. I have been trying to do so by searching for the row in matrix 'x' where the first 10 values are unique (non-repeating and converging to chaos). Can anyone help me in how to do this, or explain a better method.
Ntrans = 1024; % Set a large value to eliminate transients later
NT = 256; % Total number of iterations
r_vec = linspace(0,4,1024); % Set control parameter in an array using linspace
x_init = 0.15; % Initial Population
c = zeros(1024,257);
% Setting array index K equal to # of elements in r_vec
% Assigning r to the element of r_vec each cycle through k
% Assigning x0 to value of initial population
for k = 1:length(r_vec)
r = r_vec(k);
x0 = x_init;
% Iterate the map Ntrans times to reach asymptotic solution.
for jj = 1:Ntrans
x0 = x0*exp(r*(1-x0));
end
% Assigning first entry in array to x0
x(k,1) = x0;
% Iterate the map NT times
for j = 1:NT
x(k,j+1) = x(k,j)*exp(r*(1-x(k,j)));
end
end
figure(1)
set(gcf,'name','Bifurcation diagram','numbertitle','off')
plot(r_vec,x,'r.','Markersize',1)
grid on; box on, xlabel('r'); ylabel('lim_{n\rightarrow\infty} x_n')
title('Bifurcation diagram of the Ricker map')
xticks(0:0.5:4), yticks(0:0.5:5)
axis([0 4 0 5])
0 个评论
回答(1 个)
Walter Roberson
2023-11-23
row_has_10_unique = all(diff(sort(x(:,1:10)),2) > 0,2);
6 个评论
Walter Roberson
2023-11-23
row_has_10_unique = all(diff(sort(x(:,1:10)),[],2) > 0,2);
I tend to forget that the dimension is the third parameter to diff.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!