Casting a byte array to a struct

조회 수: 17 (최근 30일)
Amir Patel
Amir Patel 2013년 3월 22일
댓글: Walter Roberson 2022년 6월 14일
Hi
I have a data file logged in binary. I would like to read this data into Matlab to plot and perform analysis.
My question is: Can one directly define a struct in Matlab and then cast a array of binary data to it? This is easily achieved in C, but I cannot find an equivalent means in Matlab.
The alternative is ofcourse to pack each field in the struct individually, but the problem with this is that there are several structs within the data, each with 20+ fields!
Thanks in advance,
Amir

답변 (1개)

Walter Roberson
Walter Roberson 2013년 3월 22일
No, MATLAB struct fields each have separate data areas.
You should look at memmapfile
  댓글 수: 2
Reine Gill
Reine Gill 2022년 6월 14일
I have the same problem and data comes from a tcpclient so I can not use memmapfile. Is there an easy way ?
Walter Roberson
Walter Roberson 2022년 6월 14일
There is no easy way.
https://undocumentedmatlab.com/articles/serializing-deserializing-matlab-data
or look in the file exchange with keyword "serialize"

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by