MATLAB: How to access variables from base workspace in a MATLAB Function Block

addblockdataeditfunctionMATLABsimulinkvariableworkspace

How do I access variables from base workspace in a MATLAB Function Block?

Best Answer

Here are the steps to achieve the same:
1) First, navigate to the model that contains the MATLAB Function Block.
2) Second, open up the MATLAB function.
3) In the Editor tab, you can see the selection "Edit Data".
4) On clicking this, a dialog box opens up.
5) Here, go to Add->Data.
6) Change the Name to the workspace variable name, and Scope to Parameter.
The above workflow is supported for code generation as well.
The link below give details about adding data to the Matlab Function Block.