필터 지우기
필터 지우기

Is there a way to simulate a struct with a array?

조회 수: 3 (최근 30일)
Biza Ferreira
Biza Ferreira 2022년 9월 27일
댓글: Walter Roberson 2022년 9월 27일
Hello friends?
I need to implement some code I have done in C, and conver it to matlab. Can someone help me to simulate the following struct in matlab array?
typedef struct _RTC_C_Calendar
{
uint32_t seconds;
uint32_t minutes;
uint32_t hours;
uint32_t dayOfWeek;
uint32_t dayOfmonth;
uint32_t month;
uint32_t year;
} RTC_C_Calendar; // 28 bytes
struct long_byte {
union {
uint32_t val;
uint8_t id[4];
};
};

답변 (1개)

Walter Roberson
Walter Roberson 2022년 9월 27일
RTC_C_Calendar = zeros(Rows, 7,'uint32');
Now create variable names like dayOfWeek = 4;
and then you can index RTC_C_CALENDAR(row, dayOfWeek) and then the rest of your code does not need to know what the order of the fields is.
  댓글 수: 6
Biza Ferreira
Biza Ferreira 2022년 9월 27일
Hello Walter Roberson,
can you give me some help with this? I dont have a solid knowledge to do this in matlab
Walter Roberson
Walter Roberson 2022년 9월 27일
See the example at https://www.mathworks.com/help/matlab/ref/memmapfile.html#bt3tmd4-1 for handling effectively a repeated struct

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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by