- Permitting your user to choose only one of a limited number of widths and build distinct subsystems for every permitted width that hold all of the blocks that need to know about that width, with the block boundaries at the point where the computations no longer rely upon the width;
- Variant controls https://www.mathworks.com/help/simulink/ug/switching-between-variants.html
- there might be options about busses that carry around the length and an array of bytes and then at each point you switch on the length to choose the appropriate instruction and push the results back into a bus again.
Cannot use input value with 'numerictype' in MATLAB Fcn
조회 수: 1 (최근 30일)
이전 댓글 표시
The code below works fine
function y = fcn(u)
word_length = u.WordLength;
bin_pt = 5;
T = numerictype(1,word_length, bin_pt);
y = reinterpretcast(u,T);
But I want user-defined binary point and when I take it as an input (from a mask variable or a constant) it doesn't
function y = fcn(u, bin_pt)
word_length = u.WordLength;
% bin_pt = 5;
T = numerictype(1,word_length, bin_pt);
y = reinterpretcast(u,T);
This gives the following error
댓글 수: 0
답변 (1개)
Walter Roberson
2019년 5월 15일
Every signal in Simulink must be of specific type, and fixed point values of different length are considered different data types. The consistency checking is done at the time the model is to be built, but the building process compiles in specific internal routines and lengths.
Options include:
댓글 수: 3
Walter Roberson
2019년 5월 15일
function y = fcn(u)
switch u.WordLength
case 1
T = numerictype(1, 1, 5);
case 2
T = numerictype(1, 2, 5);
case 3
T = numerictype(1, 3, 5);
case 4
T = numerictype(1, 4, 5);
case list off all of the other user possibilities individually
end
y = reinterpretcast(u,T);
참고 항목
카테고리
Help Center 및 File Exchange에서 Fixed Point에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!