How to access scope data when running model with sim() command

4 views (last 30 days)
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
  1 Comment
K
K on 23 Feb 2018
Hello again,
After some intensive fiddling it I have reloaded my model and by that managed to enlist my scope structure to simout. When using simout.who the scope structure name is showing!! It seems there is no need for additional settings to the ones I have stated in the initial post.

Sign in to comment.

Answers (1)

Joel Van Sickel
Joel Van Sickel on 2 Sep 2020
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

Community Treasure Hunt

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

Start Hunting!