In order to feed into another program, I must do exactly as the title says. So far, I have been able to find the indices where a blank row is needed directly after each row number, but have been unsuccessful in adding them. I have tried using a For loop to add blank lines directly to the matrix, however vertcat had an error due to the difference in sizes as newline is a character array. Then, I figured that this may be easier if I changed the format to a table, but this was also successful. Below is the only successful part of my code. It is not necessary for the blank lines to be shown in matlab, as long as the written file has them. s= load("data.dat"); p= 1:length(s)-1; i= s(p,1) ~= s(p+1,1); y= find(i); %list of indices
Prashant Kumar answered .
2025-11-20
You can’t have blank lines in a matrix, simply:
s = [1, 2, 3;...
4, 5, 6]; % an example
[m,n] = size(s);
Wanted = reshape([s, nan(m, n)].', n, []).'