Loading table from object from .mat file

I import a table object that I have stored in a .mat file (attachment) using:
ParaDat=load('ParameterDatabase.mat')
Then, I try to assign values to the different elements of that table, e.g.
A1=ParaDat.a1
but this line generates the error message: Unrecognized field name "a1"
Also, if I try to convert the imported struct to a table using:
Dat=struct2table(ParaDat)
A1=Dat.a1
but I wtill see the same error message. How can I address the different variables of the imported table?

3 comentarios

Stephen23
Stephen23 el 7 de Abr. de 2024
Editada: Stephen23 el 7 de Abr. de 2024
Your MAT file contains one table named PARATABLE:
S = load('ParameterDatabase.mat')
S = struct with fields:
ParaTable: [1x10 table]
T = S.ParaTable
T = 1x10 table
Sample a1 b1 c1 a2 b2 c2 a3 b3 c3 ___________________ _______ ______ __________ ______ _______ _________ _______ _______ __________ {'BBX2_Isopentane'} -1.9324 9.6297 -0.0084416 4.8199 -8.5584 0.0088016 0.66304 -1.7523 -0.0019275
T.a1
ans = -1.9324
Do not LOAD directly into the workspace.
Saeid
Saeid el 7 de Abr. de 2024
OK, thanks, Stephen, but why should I NOT load directly into the workspace?
Stephen23
Stephen23 el 7 de Abr. de 2024
"why should I NOT load directly into the workspace?"
For most of the reasons listed here:

Iniciar sesión para comentar.

 Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 6 de Abr. de 2024

1 voto

If the table object in that .mat file is called MyTable, then after ParaDat=load('ParameterDatabase.mat'), you can access it by
ParaDat.MyTable
If you run load('ParameterDatabase.mat'), then you can access that table directly
MyTable

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.

Productos

Versión

R2023b

Preguntada:

el 6 de Abr. de 2024

Comentada:

el 7 de Abr. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by