Preserving More Decimal Places When Importing Excel Files with readtable in MATLAB

12 views (last 30 days)
Hello,
when I import this Excel file using readtable in MATLAB, it only retains four decimal places. I have already tried using format long, but it didn't solve the issue. How can I ensure that more decimal places are preserved?
I have attached the Excel file.
  1 Comment
Torsten
Torsten on 10 Jan 2025
Edited: Torsten on 10 Jan 2025
The table entries have exactly the same length as the entries in your Excel-file, don't they ?
format long
t = readtable("LE5_ZSW_PANA18650_Zyklenmessg_SystTBattLab.xlsx")
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
t = 6x23 table
Time_h_ DataSet DateTime t_Step_h_ t_Set_h_ Line Command U_V_ I_A_ Ah_Ah_ Ah_Charge Ah_Discharge Ah_Cyc_Discharge Ah_Step Ah_Set_Ah_ Wh_Wh_ Wh_Charge Wh_Discharge Wh_Step T_cell__C_ Cyc_Count State T_amb__C_ ___________ _______ ____________________ ___________ ___________ ____ _________ ___________ ____ ______ _________ ____________ ________________ _______ __________ ______ _________ ____________ _______ __________ _________ _____ _________ 0 1 09-Oct-2023 07:21:13 0 0 2 {'Pause'} 3.639215592 0 0 0 0 0 0 0 0 0 0 0 25.04275 1 3 24.61324 5.55e-07 2 09-Oct-2023 07:21:13 5.55e-07 5.55e-07 2 {'Pause'} 3.639215592 0 0 0 0 0 0 0 0 0 0 0 25.04275 1 0 24.61324 0.000277777 3 09-Oct-2023 07:21:14 0.000277777 0.000277777 2 {'Pause'} 3.639215592 0 0 0 0 0 0 0 0 0 0 0 25.06414 1 1 24.33477 0.000555556 4 09-Oct-2023 07:21:15 0.000555556 0.000555556 2 {'Pause'} 3.639215592 0 0 0 0 0 0 0 0 0 0 0 25.06414 1 1 24.61324 0.000833333 5 09-Oct-2023 07:21:16 0.000833333 0.000833333 2 {'Pause'} 3.639406366 0 0 0 0 0 0 0 0 0 0 0 25.06414 1 1 24.20327 0.001111111 6 09-Oct-2023 07:21:17 0.001111111 0.001111111 2 {'Pause'} 3.639215592 0 0 0 0 0 0 0 0 0 0 0 25.06414 1 1 22.64851

Sign in to comment.

Answers (1)

the cyclist
the cyclist on 10 Jan 2025
All decimal places are retained for me ...
% Change the format
format long
% Read the file
r = readtable("Lab.xlsx");
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
% Here is one of the variables (which was renamed to make it a valid MATLAB variable name)
r.U_V_
ans = 6×1
3.639215592000000 3.639215592000000 3.639215592000000 3.639215592000000 3.639406366000000 3.639215592000000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

Categories

Find more on Data Import from MATLAB in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!