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

6 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Dave B
Dave B el 24 de Nov. de 2021
Editada: Dave B el 24 de Nov. de 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 = 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' }

Más respuestas (0)

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by