MATLAB: How to get a complete record of a signal from the xPC Target using xPC Target 2.0.1 (R13SP1)

completecontinuousdatadownloadrecordscopesignalSimulink Real-Timetargetxpc

How can I get a complete record of a signal from my xPC Target using xPC Target 2.0.1 (R13SP1)?
I am running my model on an xPC Target in external mode. How can I get a complete record of a signal from the xPC Target?

Best Answer

You can use two xPC host scopes to collect the data. Have the first scope trigger the second scope and the second scope trigger the first scope. Then use a script in MATLAB to collect the data from multiple scopes and save the data into a single MATLAB variable while your simulation is running on the xPC Target.
See following steps for a complete example illustrating the above-described solution:
1) Download the files linked at the bottom of this solution and place them in a directory on your MATLAB path
2) Make sure that you are properly connected to your xPC Target box by running the XPCTEST command
3) Open the downloaded model by typing the following at at the MATLAB command prompt
test_logging
4) Build the test_logging model by selecting Simulation -> Simulation Parameters from the menu and selecting the RTW pane and clicking on the Build button
5) When the build completes successfully, type the following at the MATLAB command prompt to run the downloaded script
collect_data