Running external m-file during simulation

조회 수: 4 (최근 30일)
Pawel
Pawel 2013년 6월 17일
I'm preparing a model of heat pump in simulink. For obvious reasons I need to have actual thermodynamic parameters of fluid all time. NISTs program - Refprop is giving this possibility. I have the code in *.m file (it's a function) and I need to run it for every time step. The calculation base on two parameters from my simulink model (e.g. temp and pressure) and there is necessity to transport them into matlab workspace to use it for calculation *.m file. Is it a good way to use "Embedded Matlab function"?:
function y = fcn(u)
eml.extrinsic('assignin');
assignin('base','volume_work',u);
y = 1;
And how to trigger running calculation *.m function every time step? The result of this function is needed to continue simulink calculations...
Than a lot for every help!

답변 (3개)

Kaustubha Govind
Kaustubha Govind 2013년 6월 17일
I would recommend that you use the To Workspace block if you need to log a signal to the MATLAB workspace.
Also, the block is automatically run at every time-step, however, you are over-writing the value of the 'volume_work' variable in the workspace every time that the block is executed.

Pawel
Pawel 2013년 6월 17일
편집: Pawel 2013년 6월 18일
Thank You for answer and help, but the main problem is: how to trigger external *.m file every time step. I have no idea how to do that...
  댓글 수: 1
Kaustubha Govind
Kaustubha Govind 2013년 6월 18일
You can use the Embedded MATLAB Function block or Interpreted MATLAB Function block to call into MATLAB code in a Simulink model. Both are in the Simulink 'User Defined Functions' sub-library.

댓글을 달려면 로그인하십시오.


Pawel
Pawel 2013년 6월 18일
Up... Anyone? some tips, advices?
Please help, it's very important.
  댓글 수: 1
Jan
Jan 2013년 6월 18일
All questions are important for their authors, of course.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Model Editing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by