How to use workspace variables in simulink's matlab function?

I have a structure in workspace and intend to use its variables several times in simulink function. Creating a constant block with the "par" (name of my structure in workspace) and then passing it as an input in the function block is giving me errors.

2 Comments

Without any data, it is difficult to guess how exactly you are trying to pass the data, how you are trying to use the data in your function block and why you are getting an error. If possible share your workspace data mat file and model.
Please have a look at the attachment. I have removed other unecessary stuff to avoid confusion. I have checked and it is giving the same error.

Sign in to comment.

Answers (1)

Hi,
Here is a quick and easy solution. A small trick to make MATLAB Fcn block of Simulink to accept the data from the structure type of variable value (s) from the MATLAB workspace.
Good luck.

2 Comments

Something is wierd. Not able to download the file you attached. it is opening as a web link with wierd stuff. Could you attach a zip file instead?
Hi,
Use the right mouse button option - and click - Save link as ... that downloads the file (SIM_main.slx) into your computer.
Good luck.

Sign in to comment.

Products

Release

R2018b

Asked:

on 13 May 2019

Community Treasure Hunt

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

Start Hunting!