# Reading a mat-file whichs includes a table variable

**URL:** <https://scilab.discourse.group/t/reading-a-mat-file-whichs-includes-a-table-variable/946>\
**Category:** Matlab to Scilab\
**Created:** [May 15, 2025, 9:43am UTC](https://scilab.discourse.group/t/reading-a-mat-file-whichs-includes-a-table-variable/946 "2025-05-15T09:43:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![philipp](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/philipp/32/53_2.png) [@philipp](https://scilab.discourse.group/u/philipp)\
**Post date:** [May 15, 2025, 9:43am UTC](https://scilab.discourse.group/t/reading-a-mat-file-whichs-includes-a-table-variable/946/1 "2025-05-15T09:43:24Z")

</div>

Hallo,

I try to read mat file (generated by Matlab).

I tried `loadmatfile` and `matfile_open`.

It seems to me, that all variables are read before a `table` variable is reached.

e.g.:

`data = loadmatfile(inPath, "-toStruct");`

does work, and no error values/messages are returned.

However, `data` contains only variables which are stored before the “table-type variable”.  
Variables that follow the “table-variable” are not read.

Checking the Scilab result with `matfile_listvar` I would like to get a confirmation if `loadmatfile` and /or `matfile\_open’ do not support a Matlab - table variable.

Scanning the file with `matfile_varreadnext` I am able to read also variables “following” the “table-variable”. Does `loadmatfile` simply stop reading from a mat file when they can not read a variable?

Thank you,  
Philipp

---

<div class="post-metadata">

**Author:** ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)\
**Post date:** [May 16, 2025, 9:50am UTC](https://scilab.discourse.group/t/reading-a-mat-file-whichs-includes-a-table-variable/946/2 "2025-05-16T09:50:33Z")

</div>

Hello,

Scilab depends on matio library, which supports the following types:

> <https://github.com/tbeu/matio/blob/e827076557ef9cc7126a5b3de6fc542a05efb306/src/matio.h#L110-L130>

To save a table in Matlab and read it back in Scilab in would suggest to convert it first to a struct, e.g. (Matlab side):

```matlab
t=table([1;2;3],[4;5;6])
ts=table2struct(t);
save ts.mat ts

```

then in Scilab:

```scilab
loadmatfile ts.mat
t=struct2table(ts)

 t = [3x2 table]

   Var1 Var2
   ________
              
   1 4   
   2 5   
   3 6   

```

S.
