How to acces a simscape.logging.Node

5 次查看(过去 30 天)
I have a simulink/Simscape model, the results are logged in a variable called 'simlog'. I am struggeling to get the rotational speed from the Motor to plot it in a matlab skript.
I started to extract the informationm to a separate varibale called temp:
>> temp=(simlog.Motor_And_Load.PMSM.Permanent_Magnet_Synchronous_Motor.angular_velocity);
>> whos temp
Name Size Bytes Class Attributes
temp 1x1 8 simscape.logging.Node
>> temp
temp =
Node with properties:
id: 'angular_velocity'
savable: 1
exportable: 0
series: [1×1 simscape.logging.Series]
With plot(temp) a new figure opens every time. My goal is to have an array with time and velocity values that I can use in subplots and for further calculations. I tried it with a get but that doesn't work. Can someone please help?
>> test = get(temp, 'angular_velocity');
Path 'angular_velocity' is not a valid path for this node.
  3 个评论
Kai
Kai 2023-12-2
移动:madhan ravi 2023-12-2
Thanks for your reply. This is what the plot returns:
ans =
1×1 cell array
{1×1 Figure}
I attached the temp and the 'ans' return from the plot command. It looks like just the figure but not the datapoints are logged. Is that correct?
madhan ravi
madhan ravi 2023-12-2
移动:madhan ravi 2023-12-2
Unfortunately I can’t test MAT file either since I don’t have access to computer. But you are right it’s already a figure.

请先登录,再进行评论。

采纳的回答

Githin George
Githin George 2023-12-12
Hello,
My understanding is that you would like to store the velocity and time values of a simulation output, for a model containing Simscape blocks.
I’m assuming that the variablesimlog” is the simulation output variable exported to workspace. You can use the following code to obtain the values of angular_velocity and store them in an array.
data = simlog.Motor_And_Load.PMSM.Permanent_Magnet_Synchronous_Motor.angular_velocity.series
angular_velocity = values(data)
% the time variable is already stored in workspace as ‘tout’
You can verify these values by doing a plot of tout vs angular_velocity.
I hope this helps.
  1 个评论
Kai
Kai 2023-12-15
Hello,
many thanks for your support. It works almost a I expected it!
But with one exception: The values of 'tout' are from the simulink solver and the data comes from the simscape solver. 'angular_velocity' has a different length than 'tout' But a workaround can be to use for one variable a 'to Workspace' block and extract the time vector for all variables from it.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Logging 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by