Is there a way to get the pattern sequence form a generated graph?

1 次查看(过去 30 天)
The aim is to obtain a unique value (also know as the order in Shor's Algorithm) from the graph produced. The graph contains discrete values and depending on the parameters T and M, it will change. For example, the current parameters gives 4 different unique points before repeating it self (A pattern of repeating unique) I would like to know how I can obtain the no. of unique points it contains (not the each individual points values) from the graph. So from this graph I have attached, there is 4 unique points on the x-axis before repeating it self and I would like to know some lines of code that would give me the value 'N = 4' from the graph. If that makes sense?
.
Code:
%% Only works for 4 orders properly!!
T = 7; % Seed
P = 128; %input("Please Enter the Bit size: "); % Bit 128, 256, 512, 1024
M = 100; %input('Please Enter the Number to be Factored: '); % Number to be factorized
t = sym(1):1:sym(P); % Signal duration/length
fncT = (T.^t) - floor(T.^t/M)*M; % Alternative version to mod(a,b)
% Fast fourier Transforms 1-D
% Rearranges 'fncT' by shifting the zero-frequency component to the centre of the array
FTsignal = fft(double(fncT) - mean(double(fncT)))/numel(double(fncT));
A = fftshift(FTsignal); % Computes duscrete fourier transform of A using fft algorithm
A_mag = abs(A.*A); % Returns absolute value of each element
% Plotting Different Graphs
title('Register in superposition state')
tiledlayout(4,1)
A_ax2 = nexttile; % Creates an axes object and inputs the graph into the next empty tile of the layout
plot(A_ax2,fncT)
xlim([0 P+1]) % Sets the x axis limit
ylabel('Amplitute')
A_ax3 = nexttile;
stem(A_ax3,fncT)

回答(1 个)

Asvin Kumar
Asvin Kumar 2021-5-10
编辑:Asvin Kumar 2021-5-10
Finding periodicity using autocorrelation seems like just the example for this scenario.

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by