Uploading .mat files that contain nested structs into a datastore

12 ビュー (過去 30 日間)
Dennan
Dennan 2024 年 2 月 20 日
コメント済み: Matt J 2024 年 2 月 21 日
I would like to upload .mat file into a datastore that contains nested structs. Like so...
TestData.Unit1.Parameter 1
TestData.Unit1.Parameter 2
TestData.Unit2.Parameter 1
TestData.Unit2.Parameter 2
When I try to upload this into a datastore I cannot read the content of the fields inside the nested struct. The size of the .mat files are enormous and take a really long time to load one parameter. How do I accomplish this while still using datastore or something of the like? I know we are supposed to use fileDataStore to create the custom read function but the read function I created only displays the first level of the structs.
  2 件のコメント
Matt J
Matt J 2024 年 2 月 20 日
編集済み: Matt J 2024 年 2 月 20 日
When you say "upload" do you truly mean that the datastore reads from files stored on a remote computer? If so, maybe the reading time is predominantly due to the remote connection, rather than the file size.
Dennan
Dennan 2024 年 2 月 20 日
It is files stored on a network of computers. So there is no way to "point" to the data and call specific parameters as needed?

サインインしてコメントする。

採用された回答

Catalytic
Catalytic 2024 年 2 月 20 日
編集済み: Catalytic 2024 年 2 月 20 日
I think the wisest course would be to reorganize your data and assign each "Unit" to its own separate .mat file.
  3 件のコメント
Dennan
Dennan 2024 年 2 月 20 日
The data is write protected
Matt J
Matt J 2024 年 2 月 20 日
It wouldn't matter if the data is write-protected. You could read the data, reorganize it, and copy the reorganized data somewhere controlled by you and where you would have full read/write acess.
If for some reason you can't do that, so be it. However, one of the upsides of @Catalytic's suggestion is that if you split the data this way, you could shuffle the Parameter instances. In the form you have things now, the shuffle() command can only vary the the read-out order of the files, not the order of the Parameters within the files.

サインインしてコメントする。

その他の回答 (1 件)

Matt J
Matt J 2024 年 2 月 20 日
This example shows how to use a fileDataStore to read partial data from a .mat file
I might modify their example and use a matfile object to read the data without actually loading the entire file.
  7 件のコメント
Stephen23
Stephen23 2024 年 2 月 21 日
編集済み: Stephen23 2024 年 2 月 21 日
"How do you get to the actual data within the struct?"
Based on what you show in your comment, perhaps something like this:
S = read(fds);
S.Para1
S.Para2
Matt J
Matt J 2024 年 2 月 21 日
Based on what you show in your comment, perhaps something like this:
Yes, but the OP would like the read() operation to return this directly.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSystem Commands についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by