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

조회 수: 2 (최근 30일)
math ahd
math ahd 2021년 9월 27일
댓글: Walter Roberson 2021년 9월 27일
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

답변 (2개)

Walter Roberson
Walter Roberson 2021년 9월 27일
편집: Walter Roberson 2021년 9월 27일
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 2021년 9월 27일
hello
try this :
a = readfile('1.txt');
% or
a = freadtxt('1.txt');
  댓글 수: 1
Walter Roberson
Walter Roberson 2021년 9월 27일
... this looks like a relatively expensive operation compared to just fileread() of the file.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by