Import txt file into MATLAB for Comparison of 2 files to measure bit errors
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (2)
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));
0 Comments
Mathieu NOE
on 27 Sep 2021
hello
try this :
a = readfile('1.txt');
% or
a = freadtxt('1.txt');
1 Comment
Walter Roberson
on 27 Sep 2021
... this looks like a relatively expensive operation compared to just fileread() of the file.
See Also
Categories
Find more on Database Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!