Using readtable to import a 5x1 column from Excel is missing one element. Why??

조회 수: 6 (최근 30일)
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.

채택된 답변

Dave B
Dave B 2021년 11월 24일
편집: Dave B 2021년 11월 24일
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 = 4×1 table
LB _______ {'LB' } {'SOC'} {'LB' } {'LB' }
f3 = readtable(fn,'Range','E30:E34','ReadVariableNames',false)
f3 = 5×1 table
Var1 _______ {'LB' } {'LB' } {'SOC'} {'LB' } {'LB' }

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by