MATLAB: 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.

exporting data to filewhite spaces

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.

Best Answer

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);