Help with workspace data extraction shortcut

1 visualizzazione (ultimi 30 giorni)
Brantosaurus
Brantosaurus il 11 Nov 2022
Risposto: Amith il 11 Ago 2024
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

Risposte (1)

Amith
Amith il 11 Ago 2024
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!

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by