Import txt file into MATLAB for Comparison of 2 files to measure bit errors

1 view (last 30 days)
Hello Support team,
I want to import txt file into MATLAB which includes bianry data. I have attached the 1.txt file for your reference. The file includes very large binary data (1010) . I want to compare the bit errors between 2 different .txt file same as 1.txt.
Kindly request you to guide. I have used importdata function. but, it does not create proper array as 1.txt file does not have data in vertical position.
Awaited your feedback

Answers (2)

Walter Roberson
Walter Roberson on 27 Sep 2021
Edited: Walter Roberson on 27 Sep 2021
B1 = fileread('1.txt') - '0';
B2 = fileread('2.txt') - '0';
L1 = length(B1);
L2 = length(B2);
if L1 ~= L2
fprintf('first file is %d entries but second file is %d entries. Ignoring extra\n');
end
L = min(L1, L2);
where_not_equal = find(B1(1:L) ~= B2(1:L));

Mathieu NOE
Mathieu NOE on 27 Sep 2021
hello
try this :
a = readfile('1.txt');
% or
a = freadtxt('1.txt');

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!