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 views (last 30 days)
Show older comments
Megha Nair
on 21 May 2018
Commented: Megha Nair
on 21 May 2018
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.
0 Comments
Accepted Answer
Walter Roberson
on 21 May 2018
Edited: Walter Roberson
on 21 May 2018
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);
More Answers (0)
See Also
Categories
Find more on Standard File Formats 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!