Call M File In SIMULINK Model

140 views (last 30 days)
hardik
hardik on 18 Sep 2014
Commented: nima nabavi on 2 Sep 2020
I want to call M File In SIMULINK Model. I take one x constant , One Matlab Fnc , Matlab Fnc Output to display .
I want to x value as input in M file function and their output display in y varibale.
How can i do it ?
  1 Comment
charmingtilak
charmingtilak on 19 Sep 2017
i have to import large data in .mat file to To file function block.. kindly assist me |

Sign in to comment.

Accepted Answer

Rajiv Ghosh-Roy
Rajiv Ghosh-Roy on 18 Sep 2014
You can use the Interpreted MATLAB function block for this; it can be found under the User defined functions category in the Simulink library browser.
  3 Comments
hardik
hardik on 18 Sep 2014
Here I attached both file
huan zhang
huan zhang on 14 Jun 2019
did you solve the question and call a m file successfully in simulink?

Sign in to comment.

More Answers (2)

Shravankumar P
Shravankumar P on 18 Sep 2014
Open your simulink library
1) Select simulink in the tree view. 2) Simulink/user-defined functions/MATLAB Function 3) open a new model and place MATLAB function block in it,then double click on it 4) now write your function
function y = fcn(x)
%#codegen
y = x^2;
  2 Comments
hardik
hardik on 18 Sep 2014
I got these error
Unable to locate a C-compiler required by Stateflow and MATLAB Function blocks. Use 'mex -setup' to select a supported C-compiler.
Abdullah Alshammary
Abdullah Alshammary on 18 Apr 2016
then take this line out: %#codegen It is meant for mex to generate c code for it. Apparently you don't have mex but that's fine.

Sign in to comment.


atef
atef on 5 Sep 2016
Use the Interpreted MAT-LAB function block .... MATLAB function: TestFun(u) and it will call m file: TestFun.m
function kp = TestFun(i) kp = i*10; disp(kp); end
  2 Comments
ABISHA  P
ABISHA P on 11 Jan 2017
how to call .m file in simulink model for performing filtering operations like sliding window , savtzky golay filter , spectrogram generation, these operations are done in m file same thing has to be called in simulink ? How can i do it?

Sign in to comment.

Categories

Find more on Simulink Coder in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!