Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

m-file in Simulink

Status
Not open for further replies.

19860726

Computer
May 11, 2010
3
LT
Hi,

I would like to include m-file into Simulink workspace. Should I use 'Level-2 M-file S-Function' block, if yes, how it must be used if I want to include two variables, one is a number and second is a text.
I could simply use m-file in Matlab command window and calculate what I need, but as I would like to include m-file into Simulink model.
 
Replies continue below

Recommended for you

use an embedded function
If you don't have the toolbox you can use an S-function. Although, you would have to convert your M-code to C-code...

[peace]
Fe
 
"you would have to convert your M-code to C-code... " No you don't have to do that. S functions can be native m.

Another way of doing that is to create a user function block, which would appear to limit you to one input and one output, but I see no reason why you couldn't MUX multiple inputs into a vector. I'll try that when I am next on a suitable box.



Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
Yes, Greg you are right. My apologies. I remember using m-file S functions as well to solve nonlinear DE's in Simulink.
OP,
The"user function block" is the same as an "embedded function block". Which can handle any amount of inputs and outputs all in m-code.
Actually this is much simpler than an S-fcuntion for bergineers.
But, S-functions are far more powerful. (embedded only allows some external functions to be utilized) (whereas an m-file s-function can solve any n-order runge kutta DE as well as basic computations. ect.

[peace]
Fe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top