Defining Matlab function datatype input in Simulink

조회 수: 4 (최근 30일)
Vlastimil Kriz
Vlastimil Kriz 2019년 7월 11일
댓글: Vlastimil Kriz 2019년 7월 13일
Hello,
I have a problem to compile model with following part:
function [delayed_flag, counter] = delayed_flag(flag, counter_default, counter_prev)
if flag == true
if counter_prev == 0
delayed_flag = true;
counter = uint16(0);
else
delayed_flag = false;
counter = counter_prev - uint16(1);
end
else
delayed_flag = false;
counter = counter_default;
end
end
The problem seems to be that the 'counter_prev' input is treated as double, and I dont know how to force it to be uint16.
(Error: Data type mismatch. Output port 1 of 'xxx/Unit Delay2' is a signal of data type 'uint16'. However, it is driving a signal of data type 'double'.)
Thank your for help,
Vlasta

채택된 답변

Fangjun Jiang
Fangjun Jiang 2019년 7월 11일
In the MATLAB Funciton editor, click icon "Edit Data".
Or in Simulink, Ctrl+H to open Model Explorer, on the left column, navigate to the MATLAB function, find your data and specify the data type.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by