Is it possible log an undefined amount of data with an xPC Target File Scope?

In Simulink, a Scope or a To File block will log a data point at every time step (or at the specified sample time) from starting a simulation to stopping it (or until MatLab runs out of memory but I've never know that happen even with large simulations).
However, with xPC Target File Scopes you have to specify the number of data points you would like to log. I would like to log a data point at every time step (or a sample time as specified by myself) from starting a simulation to stopping it.
Is this possible or, for every simulation I perform, do I need to calculate how many data points I need to log?
Considering my step time is 1ms, the default 250 samples would not get me very far!

 Accepted Answer

You do not need to know how many points you will need to log. The number of samples (default 250, as you note) is most relevant for triggering: 250 contiguous samples will be logged after each trigger. If you are not using triggering, you can leave it at 250 or increase to some value such as 1000 (this helps act as a buffer in case the file writing falls behind momentarily).

3 Comments

Maybe my setup is not quite right. The information for my scope is below.
xPC Scope Object
Application = xPC_Scope_Test
ScopeId = 2
Status = Interrupted
Type = File
NumSamples = 250
NumPrePostSamples = 0
Decimation = 1
TriggerMode = FreeRun
TriggerSignal = 4 : Signal1
TriggerLevel = 0.000000
TriggerSlope = Either
TriggerScope = 2
TriggerSample = 0
FileName = c:\data.dat
WriteMode = Lazy
WriteSize = 512
AutoRestart = off
DynamicFileName = off
MaxWriteFileSize = 536870912
Signals = 4 : Signal1
1 : Signal2
As you can see the TriggerMode is set to FreeRun and so I assumed the scope would not be triggering of any signal. However, the TriggerSignal is set to signal id #4. Either way, the simulation lasts for 2 seconds, however, I still only get 0.25 seconds worth of data because it is only capturing 250 samples. If you have any advice on what to change so that I capture data across the full 2 seconds without having to do...
scope.NumSamples = Length of Simulation/Time Step;
I would be very grateful
You would need to turn scope.AutoRestart='on' and that should do the trick.
Perfect! Worked a treat.
Thank you very much.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!