One of the outputs of the automated fixed-point conversion workflow in either Fixed-Point Converter or MATLAB Coder is a "wrapper" function that can help take care of type conversions. You can take this function and run it through MATLAB Coder either separately or as an additional entry-point.
As an example, let’s say you’ve generated fixed-point MATLAB code for a single function “foo” using the automated workflow in either the Fixed-Point Converter app or MATLAB Coder app. By default, you’ll probably wind up with a new folder named something like “codegen/foo/fixpt”. In this folder, you’ll find three files of note for the task at hand. Specficially, these will be foo_fixpt.m (the converted fixed-point MATLAB code), foo_wrapper_fixpt.m (the wrapper function mentioned above), and foo_fixpt_args.mat (auxiliary information). Assuming such an example setup, the code below would demonstrate a workflow that may be of help to you.
% Either move/copy the files in % Set up your config however you'd like cfg = coder.config('lib'); cfg.GenerateExampleMain = 'GenerateCodeOnly';
values = load('foo_fixpt_args'); fiInputTypes = values.values.inputArgs;
% Generate code using either one or both entry points (unwrapped foo_fixpt and wrapped foo_fixpt). % Replace the input types of the wrapper function below with your original floating-point input types. codegen foo_fixpt -args fiInputTypes foo_wrapper_fixpt -args {0,0} -config cfg -report