Recognizing empty spaces in excel file
5 views (last 30 days)
Show older comments
Imagine a section of an Excel file of the form shown below:
I can already have MATLAB find the values under the column named "AMPLITUDE" using:
[NUMM,STRR,RAWW]=xlsread('FILENAME.xlsx',1);
[ii,jj] = find(strncmpi(RAWW, 'AMPLITUDE',10))
However, I want my array to be limited to the values starting immediately under the Title AMPLITUDE and ending before the next series start (again at Q1, then Omega/Hz etc.). In this case I am only interested at the values between 0,268 and 399,729. How can I limit the reading to this section without explicitly knowing the number of lines containing these values?
0 Comments
Answers (1)
Guillaume
on 25 Jan 2017
Edited: Guillaume
on 25 Jan 2017
[~, ~, raw] = xlsread(somefile, 1);
[startrow, ~] = find(strncmpi(raw, 'AMPLITUDE', numel('AMPLITUDE')));
endrow = find(cellfun(@(x) ~isstr(x) && isnan(x), raw(startrow:end, startcol)), 1);
selecteddata = raw(startrow:endrow, :)
%or
selecteddata = cell2table(raw(startrow+1:endrow, :), 'VariableNames', matlab.lang.makeValidName(raw(startrow, :)))
0 Comments
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!