MATLAB Answers

How to shift the entire columns in raw file to the left and hence deleting all the empty columns in the sheet in matlab?

1 view (last 30 days)
sachin narain
sachin narain on 9 May 2018
Answered: dpb on 9 May 2018
I have imported a table from excel sheet into a uitable.There are empty columns in it.I want replace these empty columns with the next columns in the sheet.
As you can see in the table attached,there are empty columns.I want to delete these empty columns and shift the columns which are next to it to the left. My new table should contain no empty columns
[~,~,raw2] = xlsread(filename,'Markings');
[rows2 ,columns2] =size(raw2);
for k =2:rows2
for l=2:columns2
if ~isnan(raw{k,l})
tempRaw2(l-1,k-1) = matchStr2;
end
Kindly help me with this.

  0 Comments

Sign in to comment.

Answers (1)

dpb
dpb on 9 May 2018
t=readtable(filename,'Sheet','Markings'); % tables are much more simpler than raw cell arrays
ix=~all(ismissing(t)); % find columns with no data, complement is any
t=t(:,ix); % save only those...
Will have to clean up the existing sheet to write a clean one; if just writetable the new table beginning at A1 will leave the existing data past the last column as it was.

  0 Comments

Sign in to comment.

Sign in to answer this question.