필터 지우기
필터 지우기

Find first row where the first 10 elements of that row are unique from each other

조회 수: 6 (최근 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])

답변 (1개)

Walter Roberson
Walter Roberson 2023년 11월 23일
row_has_10_unique = all(diff(sort(x(:,1:10)),2) > 0,2);
  댓글 수: 6
Reece
Reece 2023년 11월 23일
format long g
x204 = x(204,1:10);
sx204 = sort(x204)
diff(sx204)
sx204 =
1 1 1 1 1 1 1 1 1 1
ans =
0 0 0 0 0 0 0 0 0
When I inspect x, the rows in question do not show any difference of value of any order.
Is there a way to impliment into the statement that the values must differ greater than 'epsilon' for the statement to be true?
Thanks again
Walter Roberson
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 CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by