Question
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
Expert Answer
Prashant Kumar
PhD Expert
Answered Aug 25, 2026
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, []).'
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related matrix Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →