Unable to define type of persistent variable inside Simulink Matlab function block
古いコメントを表示
Hi,
Attached is a simple system demonstrating what I want to do and so far haven't figured out a way to do.
I would like to run my system using doubles to debug, then convert to fixed-point. The best way I know to do this in a large system is to define a data type, eg: dt_var = fixdt(1, 20, 4);, then refer to it where needed.
I have a Simulink module that's a Matlab function. In it is a persistent variable whose type I'd like to define using the data type I defined:
function y = fcn(u)
% A rather useless function that demonstrates the issue
persistent a
if isempty(a)
a = fi(0, dt_var); % dt_var is undefined
end
y = u;
a = y;
The code inside the if isempty... clause demonstrates what I'd like to do, but cannot, because dt_var is not known inside the function context.
The main problem is for me to be able to access the type dt_var from within the Matlab block. Also, it seems that the compiler doesn't like fixdt within the Matlab function context either:
Function 'fixdt' not supported for code generation.
I should add that I will be using HDL Coder in my actual system, so a solution will have to work in that context.
How do I do this?
Thanks,
Charles
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Simulink Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
