Loading table from object from .mat file

29 views (last 30 days)
Saeid
Saeid on 6 Apr 2024 at 20:37
Commented: Stephen23 on 7 Apr 2024 at 16:47
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 Comments
Saeid
Saeid on 7 Apr 2024 at 15:12
OK, thanks, Stephen, but why should I NOT load directly into the workspace?

Sign in to comment.

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 6 Apr 2024 at 21:39
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

More Answers (0)

Categories

Find more on Tables in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!