how to generate MATLAB code from Simulink model

527 ビュー (過去 30 日間)
Keymand Kiani
Keymand Kiani 2018 年 10 月 26 日
回答済み: EDMOND 2023 年 7 月 22 日
Hi, I have a relatively complex simulink model, from which a MATLAB code must be generated. I want to use the generated code in App designer to develop an app and finally compile the app using `Application Compiler`, so that it can be used on every system without having MATLAB installed. The process can be summed up as the following: Simulink --> MATLAB code (.m) --> App Designer --> Application compiler (.exe)
  4 件のコメント
Keymand Kiani
Keymand Kiani 2018 年 10 月 30 日
Unfortunately it doesn't work that way; because it must be a stand-alone executable data at the end. as far as MATLAB is instaled and opened it is no problem. The solution that I've found so far is to convert the simulink model to c/c++ code and using mex function to recall it in the MATLAB script. But it doesn't seem to be easy and you have to modify the c++ code that is generated from simulink model! well you must have deep knowledge in c/c++ and MATLAB to handle it.
Kevin Chng
Kevin Chng 2018 年 10 月 31 日
you generate MATLAB Code from Simulink?


回答 (4 件)

Walter Roberson
Walter Roberson 2018 年 10 月 31 日
There is no support for what you are doing.
You can use Simulink Real Time Explorer, using instrument panels for user interaction.

Eric Sargent
Eric Sargent 2020 年 12 月 9 日
編集済み: Eric Sargent 2020 年 12 月 9 日
As of R2020a you can use Simulink Compiler to compile your model and use it with your deployed / compiled App Designer app.
More information about Simulink Compiler can be found here:

puli 2022 年 10 月 5 日
編集済み: Walter Roberson 2022 年 10 月 5 日
image = imread('jump.jpg'); % read image
Error using imread>get_full_filename
File "jump.jpg" does not exist.

Error in imread (line 372)
fullname = get_full_filename(filename);
% get image dimensions: an RGB image has three planes
% reshaping puts the RGB layers next to each other generating
% a two dimensional grayscale image
[height, width, planes] = size(image);
rgb = reshape(image, height, width * planes);
imagesc(rgb); % visualize RGB planes
colorbar on % display colorbar
r = image(:, :, 1); % red channel
g = image(:, :, 2); % green channel
b = image(:, :, 3); % blue channel
The result is:
  1 件のコメント
Walter Roberson
Walter Roberson 2022 年 10 月 5 日
How does this answer the Question about compiling Simulink ?


EDMOND 2023 年 7 月 22 日
How to convert binary code to gray code in matlab


Help Center および File ExchangeSimulink Coder についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by