model(...) command for simscape multipbody models

1 ビュー (過去 30 日間)
Jan Sieber
Jan Sieber 2016 年 5 月 16 日
回答済み: Steve Miller 2022 年 11 月 30 日
What is the correct way of setting the evaluation point in the model(...) command? I plan to evaluate time derivatives of a simmechanics (simscape multibody) model at various states. The documentation states that the second argument is the state, but the output appears to be independent from the state. A minimal example:
%%test mdlapi on mech_dpen
clear
open('mech_dpen'); % open double pendulum example
vm = mech_stateVectorMgr('mech_dpen/Ground');
xini=mech_set_states(vm)'; % example of state (=[0,0,...])
nstates=length(xini); % called nstates
xtest=xini(ones(nstates,1),:)+eye(nstates); % array of perturbations
%%Compile model using mdlapi and evaluate derivatives in perturbations
[sys,x0,str,ts] = mech_dpen([],[],[],'compile');
for i=nstates:-1:1
dxdt(i,:)=mech_dpen(0,xtest(i,:),[],'derivs');
end % dxdt are all 0
mech_dpen([],[],[],'term');
This results in all dxdt equal to exactly zero[*], while according to documentation it should return the time derivatives in xtest(i,:). Am I using the interface wrongly? I plan to use this interface to call a model (more complicated, with loop topology) in my own optimization/parameter continuation routines.
Version of matlab used:
>> ver
MATLAB Version: 8.4.0.150421 (R2014b)
...
Operating System: Linux 2.6.32-431.20.3.el6.x86_64 #1 SMP Thu Jun 19 14:01:59 CDT 2014 x86_64
Java Version: Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
[*] Note that it also gives warnings. I get the same result, when I feed in a structure as second argument of mech_dpen(...).

採用された回答

Steve Miller
Steve Miller 2022 年 11 月 30 日
Hi Jan,
The model(...) command is not intended for use with Simscape products. This interface has been around since R2007a and is intended for use with built in Simulink blocks only. See documentation.
I know you are working in an older release. This has been documented for some time.
While you may get it to work for some Simscape Multibody 1G models, for complex models using the current version of the Simscape Multibody library it is unlikely to work. The documentation page highlights a number of other workflows that may get you what you need.
--Steve

その他の回答 (0 件)

カテゴリ

Find more on Simscape Multibody in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by