model(...) command for simscape multipbody models
1 ビュー (過去 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
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');
end % dxdt are all 0
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:
MATLAB Version: 220.127.116.11421 (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 2022 年 11 月 30 日
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.