Using readtable to import a 5x1 column from Excel is missing one element. Why??
4 views (last 30 days)
Show older comments
Emmanuel J Rodriguez
on 24 Nov 2021
Commented: Emmanuel J Rodriguez
on 24 Nov 2021
I feel like this should be a super easy fix. This is a simple import using readtable, the f3 variable below only brings in a 4x1 column vector when all others bring in a 5x1 (as it should be). Why?
f1 = readtable("Copy - DOE Input Data Set #1 -updated.xlsx",'Range','C30:C34');
f2 = readtable("Copy - DOE Input Data Set #1 -updated.xlsx",'Range','D30:D34');
f3 = readtable("Copy - DOE Input Data Set #1 -updated.xlsx",'Range','E30:E34');
f4 = readtable('Copy - DOE Input Data Set #1 -updated.xlsx','Range','F30:F34');
Excel file attached.
0 Comments
Accepted Answer
Dave B
on 24 Nov 2021
Edited: Dave B
on 24 Nov 2021
readtable detected the first value as a variable name
Just add 'ReadVariableNames', false to your call to readtable (if you don't specify, MATLAB will guess. f1,f3,f4 were all numeric so MATLAB guessed they weren't variable names).
fn = "https://www.mathworks.com/matlabcentral/answers/uploaded_files/811514/Copy%20-%20DOE%20Input%20Data%20Set%20%231%20-updated.xlsx"
f3 = readtable(fn,'Range','E30:E34') % MATLAB guesses that (the first) LB is the Variable Name
f3 = readtable(fn,'Range','E30:E34','ReadVariableNames',false)
More Answers (0)
See Also
Categories
Find more on Spreadsheets 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!