- 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 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
![matlab_error.PNG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/219047/matlab_error.png)
0 commentaires
Réponses (1)
Walter Roberson
le 15 Mai 2019
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 commentaires
Walter Roberson
le 15 Mai 2019
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);
Voir également
Catégories
En savoir plus sur Fixed-Point Designer dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!