Matlab code to simulink model for android
1 view (last 30 days)
Show older comments
Anuja Vats
on 5 Oct 2017
Commented: Walter Roberson
on 5 Oct 2017
I have written code for lane detection in MATLAB, Now I want to bring it to a simulink model with image input from android camera. Currently the matlab code calls a lot of functions,please tell me how to convert this code to simulink block. with a working simulink model I aim to bring it to android SDK n make an android app.
0 Comments
Accepted Answer
Walter Roberson
on 5 Oct 2017
You can put MATLAB code into an MATLAB Function Block and have your Simulink model pass appropriate signals to it, such as from an Android Camera https://www.mathworks.com/help/supportpkg/android/ref/camera.html
There are a number of restrictions on what function calls can be part of a MATLAB Function Block; see https://www.mathworks.com/help/simulink/ug/functions-supported-for-code-generation--categorical-list.html
Also, you mostly need to initialize variables with the proper size and type before you use them, and you cannot change type after the first assignment. You can make variables smaller after the first assignment, but making them larger requires special calls.
2 Comments
Walter Roberson
on 5 Oct 2017
You are thinking of Simulink as being procedural, like you have to loop to read frames. Simulink is for model based design: all the parts of it are active at the same time (unless there are triggered subsystems or the like) and inputs (perhaps just clocks) flow in and out for each component at each time step. You would put in a camera block, and once it gets going, each timestep the block would output another image on the ports.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!