Check MATLAB Function for Unsupported Calls
Debug the MATLAB® function and ensure if all the calls in the function are supported by code generation.
To fix unsupported function call errors, perform one of these steps:
Declare the function as coder.extrinsic: When you declare a function call as an extrinsic function, the code generator does not produce code for that function. It instead dispatches them to MATLAB for execution. For more information, see Declaring MATLAB Functions as Extrinsic Functions (MATLAB Coder).
Replace with an equivalent call supported by code generation: Replace the unsupported calls with an equivalent call that is supported by code generation. Including calls supported by code generation ensures that the function will behave the same as tested in Run the Function Using Live IO from Hardware after the deployment.
Some calls supported by code generation are listed here:
For example, the
pause
function is not supported by code generation but it is used at line numbers 11 and 15 of theblinkLED
function. Deploying theblinkLED
function without any modification results in an executable that may not behave as expected.To fix this unsupported call error, replace
pause
with an equivalent function supported by code generation. You can replicate the functionality of thepause
function by using thesystem
function provided by the MATLAB Support Package for Raspberry Pi® Hardware. Provide the Linux® terminal command,sleep
, as the input argument to thesystem
function.function blinkLED() %#codegen % Create a Raspberry Pi object r= raspi(); % Blink the LED for 100 cycles for count = 1:100 % Turn on the LED writeLED(r,'LED0', 1); % Pause for 0.5 seconds system(r, 'sleep 0.5'); % Turn off the LED writeLED(r,'LED0', 0); % Pause for 0.5 seconds system(r, 'sleep 0.5'); end end