Hello. Here's what I am trying to do.
1. Read in data from Excel in a cell array.
2. Delete the empty rows (i.e., rows with no data).
3. Write the array to a sheet in Excel.
So far, my code deletes the first empty row but then goes no farther.
Here is what I have based on https://stackoverflow.com/questions/31818057/deleting-empty-rows-in-a-cell-array:
[~, ~, DeleteEmptyWilliams]=xlsread('StimuliInExcel.xlsx', 'WilliamsList') for m = 1:124 NewWilliams=DeleteEmptyWilliams(~all(cellfun('isempty',DeleteEmptyWilliams(:,1:8)), 2),:) end xlswrite('StimuliInExcel.xlsx',NewWilliams,'WilliamsListNoEmpty')
I have also tried the following code by adding (m,1:8), but it doesn't work either—instead, I get this error: "Index exceeds matrix dimensions". I expect this error occurred because I am deleting rows as I go, so the array's dimensions change.
[~, ~, DeleteEmptyWilliams]=xlsread('StimuliInExcel.xlsx', 'WilliamsList')for m = 1:124 NewWilliams=DeleteEmptyWilliams(~all(cellfun('isempty',DeleteEmptyWilliams(m,1:8)), 2),:)endxlswrite('StimuliInExcel.xlsx',NewWilliams,'WilliamsListNoEmpty')
I tried the following code based on the suggestion at https://www.mathworks.com/matlabcentral/newsreader/view_thread/164617, but that did not work. I get this error: "Input array is empty".
[~, ~, DeleteEmptyWilliams]=xlsread('StimuliInExcel.xlsx', 'WilliamsList')for m = 1:124 NewWilliams=DeleteEmptyWilliams(all(cellfun(@isempty,DeleteEmptyWilliams(:,1:8)), 2),:)endxlswrite('StimuliInExcel.xlsx',NewWilliams,'WilliamsListNoEmpty')
I would appreciate any help you can provide.
Best Answer