Import txt file into MATLAB for Comparison of 2 files to measure bit errors
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (2개)
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));
댓글 수: 0
Mathieu NOE
2021년 9월 27일
hello
try this :
a = readfile('1.txt');
% or
a = freadtxt('1.txt');
댓글 수: 1
Walter Roberson
2021년 9월 27일
... this looks like a relatively expensive operation compared to just fileread() of the file.
참고 항목
카테고리
Help Center 및 File Exchange에서 Database Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!