MATLAB: Linking simulink from m-file

m-fileMATLABsimulink

By using sim('modelname'); i can open a model from m-file.but if i want to get a particular data/signal from the simulated model,such that the data/signal will be stored in a variable.then what command should i use?

Best Answer

This is a matter of the return variables of the SIM command. This examples code is from the documentation:
Specify parameter name-value pairs within the sim command:
simOut = sim('vdp','SimulationMode','rapid','AbsTol','1e-5',...
'SaveState','on','StateSaveName','xoutNew',...
'SaveOutput','on','OutputSaveName','youtNew');
Important is, that you need - like in this example - an "out" Block at the end of the relevant signal(s).