Extraction of struct dataset

1 回表示 (過去 30 日間)
Sidharth Raut
Sidharth Raut 2023 年 5 月 1 日
コメント済み: Sidharth Raut 2023 年 5 月 4 日
Hello there,
I'm trying to perfrom FLIR post-processing on IR datasets. I've generated the IR data in .mat format and imported it into MATLAB. MATLAB reads the IR file as 1x1 struct which is having 2879 fields. Now, I want to extract the number of frames on which I need to perform the post-processing but I cannot to extract the file altogether. I tried the following command:
DATA1=horzcat(DATA.Frame21);
But the problem with this is that it only extract single frame. Is there a way to extract 2879 frames altogether? I tried performing for loop but it's not working. Can you please suggest a way to extract the number of frames from struct file?
Thanks in advance.
  2 件のコメント
Stephen23
Stephen23 2023 年 5 月 1 日
Sidharth Raut
Sidharth Raut 2023 年 5 月 1 日
Hello Stephen23,
Thanks for your suggestion. However, with struct2cell option, I'm getting 2879x1 cell dataset which still have all the consolidated datasets, i.e. number of frames, frames_datatime and objectparam. I need only to extract number of frames ( in double) to perform the post-processing. Can you suggest me how to do that?

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

採用された回答

Daniel Dolan
Daniel Dolan 2023 年 5 月 3 日
I will assume that every frame is a 2D array of the same size. Use the first array to preallocate a 3D array, each layer of which holds one 2D array. Then loop through the each frame, generating the appropriate field name with sprintf.
N=2879;
result=repmat(DATA.Frame1,[1 1 N]);
for n=2:N
name=sprintf('Frame%d',n);
result(:,:,n)=DATA.(name);
end
There is lots of room for improvment here--just showing the highlights now. If the arrays are larger than 2D, this code can be tweaked to add another dimension.
  1 件のコメント
Sidharth Raut
Sidharth Raut 2023 年 5 月 4 日
Hello Daniel,
Thanks for your suggestion, it works well.

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

その他の回答 (1 件)

Daniel Dolan
Daniel Dolan 2023 年 5 月 3 日
I will assume that every frame is a 2D array of the same size. Use the first array to preallocate a 3D array, each layer of which holds one 2D array. Then loop through the each frame, generating the appropriate field name with sprintf.
N=2879;
result=repmat(DATA.Frame1,[1 1 N]);
for n=2:N
name=sprintf('Frame%d',n);
result(:,:,n)=DATA.(name);
end
There is lots of room for improvment here--just showing the highlights now. If the arrays are larger than 2D, this code can be tweaked to add another dimension.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by