How to access scope data when running model with sim() command
Show older comments
Dear all,
How can one access scope logged data when model simulation is being run programmatically via sim() command?
My scope's 'Log data to workspace' is ticked and a 'Structure with time' option is chosen. The model simulation is being run using
simout = sim('piCAN.slx','StopTime','1e-2');
When simulation finishes I am using
simout.who
which outputs the following:
T57_5445_5418679284029 T58_5494_5603446628436 T58_5495_5601240690699 T58_5496_5599105202616 tout
which may (or may not) correspond to the 4 MUXed signals connected to my scope. I can access what seems to be a time vector using
simout.get('tout')
but its dimension as shown by the size() function is different from the scope time vector dimension when the the model is being run manually.
As for the signal values/data, when trying to access the other variable using get function I get a blank 0x3 double array as follows
>> simout.get('T57_5445_5418679284029').signals
ans =
values: [0x3 double]
dimensions: 3
label: ''
I have tried to change my model's destination workspace using
simset('DstWorkspace', 'base')
but could not get anywhere.
Any help/suggestion would be highly appreciated.
Kind regards, Dag
Answers (1)
Joel Van Sickel
on 2 Sep 2020
0 votes
Hello K,
it sounds like you may have solved your issue. In general, I would use the Simulink Data Inspector for this task. https://www.mathworks.com/help/simulink/slref/simulationdatainspector.html
Regards,
Joel
Categories
Find more on Data Logging in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!