Calling SimMechanics which requires input variables from matlab function

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 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 10 月 29 日
your tags are not correct (simulink & simechanics are products).
your question is not clear for me
Dave
Dave 2012 年 11 月 1 日
Thanks for your response. Could you please tell me what the tags should be instead for future reference?
Walter Roberson
Walter Roberson 2012 年 11 月 2 日
The tags should be descriptive of the problem to be solved; see http://www.mathworks.co.uk/matlabcentral/answers/43073-a-guide-to-tags

サインインしてコメントする。

 採用された回答

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 件のコメント

Dave
Dave 2012 年 11 月 1 日
Thanks that works! Exactly what I was looking for.
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 件)

カテゴリ

ヘルプ センター および File ExchangeProgrammatic Model Editing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by