Hi, How to remove white spaces from A=[1 0 0 0 1] binary data & how to copy the binary data in A to a text file?. Thanks in advance.

조회 수: 4 (최근 30일)
1. I tried using ~isspace command but i am getting the same output with space.
2. I tried fprintf, but the generated file contains something like cubes symbol. Which format in 'formatspec' will get this right for me?
I need something like this when A=[1 0 0 0 1] is given as input.
1* A=[10001]
2* A.txt should contain the 1*
Please help.

채택된 답변

Walter Roberson
Walter Roberson 2018년 5월 21일
편집: Walter Roberson 2018년 5월 21일
fid = fopen('A.txt', 'wt');
fprintf(fid, '%d', A);
fprintf(fid, '\n');
fclose(fid);
Or:
fid = fopen('A.txt', 'wt');
fprintf(fid, '%s\n', char(A+'0'));
fclose(fid);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Standard File Formats에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by