simulink Embedded MATLAB Function

Status
Not open for further replies.

hameeds01

Advanced Member level 2
Joined
Aug 23, 2005
Messages
599
Helped
75
Reputation
156
Reaction score
41
Trophy points
1,308
Location
Islamabad Pakistan
Activity points
4,540
Hello everyone
I would appreciate if someone could help me, I am using “Embedded MATLAB Function” block in Simulink matlab, the problem is that I want to store the previous values of the variables that I am using in Embedded MATLAB Function block just like M-file code secondly I want to make them appear in workspace How I can do that ??





Regards
Engineer Asad Hameed
 

Why dont you use MATLAB function?

It is more closer to matlab syntax

Faster than embedded

Reliable for computing

And you can define its variables in workspace using global type variables
 

function [fnc2]=fnc2(M)

global fnc2;
global T;
global Jg;

fnc2=M*T/Jg;

end

This is a simple example. fnc2 output M input

Global adjective means variables are stored in workspace. If your output or input ports are vector, there is no need for change the syntax in first line.

For different rows of vector you can use fcn2(1),fcn2(2)... etc.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…