How to set column and row index of .txt-file for the use of dlmwrite - text editor doesnt show the right column and row index

1 view (last 30 days)
Hello,
i have a problem concerning dlmwrite. I basically just want to write a matrix into a .txt file. Matlab recognizes the right number of column and rows when reading, the .txt editor however, doesnt. The editor fills up each row.
[FileName,PathName] = uigetfile('*.txt', 'Open text file','MultiSelect','on'); data = zeros(1043,2,length(FileName)) ;
for i = 1:length(FileName)
file = load(fullfile(PathName,FileName{i}));
data(:,:,i) = file;
end
data_mean=zeros(1043,2);
data_mean=mean(data(:,:,:),3);
dlmwrite('test.txt',data_mean,'delimiter',' ');
I hope I was specific and someone might know what my problem is. I just want to see the right number of columns and rows in the .txt editor

Answers (1)

Cris LaPierre
Cris LaPierre on 20 Nov 2018
It is likely the newline character is not being recognized. Consider adding a newline name-value pair to your dlmwrite command.
dlmwrite('test.txt',data_mean,'delimiter',' ','newline','pc');
It works for me (on a pc).

Community Treasure Hunt

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

Start Hunting!