필터 지우기
필터 지우기

Help with workspace data extraction shortcut

조회 수: 13 (최근 30일)
Brantosaurus
Brantosaurus 2022년 11월 11일
답변: Amith 2024년 8월 11일 3:56
I am trying to extract data from the workspace from various possible locations.
X.output.name.param1(:,end)
X.output.name.param2(:,end)
:
X.output.name.paramN(:,end)
If possible, I would like to try access it via a named parameter, like below.
line 1: param = 'param2';
line 2: y = X.output.name.(param);
Doing this partly appears to work. I can see my data as a 25x3 matrix.
But how do i home in on the 3rd 'end' column by editing line 2, and not line 1?
Regards, Dave

답변 (1개)

Amith
Amith 2024년 8월 11일 3:56
Hi Dave,
  1. From Workspace Block:
  • Use the From Workspace block in your Simulink model. This block reads data from a workspace and provides it as a signal or a nonvirtual bus at the block’s output1.
  • To read more about "From Workspace" block, click the link below - https://www.mathworks.com/help/simulink/slref/fromworkspace.html
  • Specify the data you want to load using the Data parameter. You can use a MATLAB expression (e.g., a variable name) that evaluates to data in a format supported by the block.
  • Connect the output of the From Workspace block to your desired location in your model.
2. Accessing Logged Data:
  • If you’re logging data using a To Workspace block, you can access the logged data using the variable name specified in the Variable name parameter of the block2.
  • Use a dot notation with the variable name to access specific columns or elements.For example:
% Assuming 'simout' contains your logged data
y = simout.param2(:, end); % Access the 3rd 'end' column
3. Model Workspace
Hope this helps!

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by