필터 지우기
필터 지우기

Calculate the size in bytes of a bus signal

조회 수: 18 (최근 30일)
Eleni T
Eleni T 2022년 5월 6일
답변: Gagan Agarwal 2023년 9월 27일
Hello,
I have a bus signal which contains data and i would like to calculate the total size of these data in bytes. Is there a way in simulink?
Thank you
  댓글 수: 1
dpb
dpb 2022년 5월 6일
Write an S function if nothing else...with nothing else to go on, one would presume it's simply the numel() * data width.

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

답변 (1개)

Gagan Agarwal
Gagan Agarwal 2023년 9월 27일
Hi Eleni,
I understand that you are trying to find an approach to calculate the data size (in Bytes) of a bus signal in Simulink.
To calculate the size of a bus signal, please follow these steps:
1. Create a bus object using the “Simulink.BusElement function.
2. Retrieve the data type of each element by accessing the “DataType property of the bus object. Please refer to the attached screenshot for the output of the "Datatype" property.
3. Create an array to store the sizes of each data type. Please refer to the following documentation on numeric types for a comprehensive list of data types and their corresponding sizes: https://www.mathworks.com/help/matlab/numeric-types.html
4. Calculate the size of each element by mapping its data type to the corresponding size in bytes.
5. Store the sizes of each element in the array and sum up all the elements of the array to obtain the size of one bus signal.
For additional information regarding Simulink.BusElement”, please refer to the following documentation: -
I hope this helps!

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by