⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 decrypt_vigenere.m

📁 loading a text file from a directory to your workspace in matlab
💻 M
字号:
%% Coincidence Counting Programclose all;clear all;clc;%% Read the cyphered text from a *.txt filetext_input = loadtext('Decrypt_3.txt');%% Remove the blanks from input text.index = find(text_input ~= ' ');text = text_input(index);%% len = length(text);shmax = len-1;count=0;results = zeros(shmax,3);for m=1:shmax        % Rotate text relative to itself by m spots    teststr=[text(m+1:end) text(1:m)];        % Count number of matches    for i=1:len        if teststr(i)==text(i)            count=count+1;        end    end        results(m,1) = m;    results(m,2) = count;        % Normalize the count by the length of the string    results(m,3) = count/len;        % Reset count for next iteration    count=0;end% What does this do?  Try to make sense of it!resultsmax_m=find(max(results(:,3))==results(:,3))max_norm_count=max(results(:,3))f=find(results(:,2)>19);results(f,:)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -