Calling SimMechanics which requires input variables from matlab function

조회 수: 4 (최근 30일)
I am calling my simMech model from my matlab function using sim('mymodel.mdl') in a matlab function file. Only problem is that the model cannot run because I need it to take parameters that are defined in my function (e.g. initial conditions on a joint is specified as 'jointIC' in the simMech model and in my matlab function I have jointIC = 0;) Furthermore I need to pass the outputs of the model back to my function.
I know that you can do what I have described for script files in matlab i.e the variables are passed back and forth from the matlab workspace. But in my case it is very important that I pass them via my function!
Any input would be appreciated, thanks!
  댓글 수: 3
Dave
Dave 2012년 11월 1일
Thanks for your response. Could you please tell me what the tags should be instead for future reference?

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

채택된 답변

Kaustubha Govind
Kaustubha Govind 2012년 10월 30일
You need to pass in some additional options to the SIM command to make sure that the model reads and writes to the function workspace instead of the base workspace.
options = simset('SrcWorkspace','current', 'DstWorkspace', 'current');
sim('mymodel.mdl', options);
  댓글 수: 3
Kaustubha Govind
Kaustubha Govind 2012년 11월 2일
Dave: Could you please accept my answer? Thanks!
Dave
Dave 2013년 1월 5일
Sorry for the belated accepted answer...

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by