How to use simulink output in matlab for graphs?

8 次查看(过去 30 天)
I've been trying to use MATLAB and the "To Workspace" block in SIMULINK to call some data to be used in some plots but i'm just getting errors that MATLAB is "Unable to resolve the name 'out.____'" no matter what i've tried. Below is the code and attached are all the files.
I wanted to automate it using a loop but that just gave me more trouble so I resorted to just going line by line.
% Constants
%% For Evans Blue
Vpls = 3.5; % Blood Plasma Vol (L)
%% For Inulin
Vecf = 14; % Extracellular Fluid Vol (L)
kIu = 1.4; % Loss of Inulin (L/min)
%% For Antipyrine
Vtbf = 42; % Total body fluid Vol (L)
kAu = 2.1; % Loss of AP by excretion (L/min)
kAm = 0.84; % Loss of AP by metabolism (L/min)
Select = 1;
figure % Evans Blue Graphs
Select = 1; % Setting for Continuous
subplot(2,1,1)
sim('Lab3EB.slx');
plot(out.Eout)
xlabel('Time (min)')
ylabel('Concentration (mg/L)')
title('Evans Blue Continuous')
clear out
Select = -1;% Setting for Bolus
sim('Lab3EB.slx');
subplot(2,1,2)
plot(out.Eout)
xlabel('Time (min)')
ylabel('Concentration (mg/L)')
title('Evans Blue Bolus')
figure % Inulin Graphs
Select = 1; % Setting for Continuous
subplot(2,1,1)
sim('Lab3In.slx');
plot(out.Iout)
xlabel('Time (min)')
ylabel('Concentration (mg/L)')
title('Inulin Continuous')
Select = -1; % Setting for Bolus
subplot(2,1,2)
sim('Lab3In.slx');
plot(out.Iout)
xlabel('Time (min)')
ylabel('Concentration (mg/L)')
title('Inulin Bolus')
Select = 1;
Select = 1; % Setting for Continuous
subplot(2,1,1)
sim('Lab3AP.slx');
plot(out.Aout)
xlabel('Time (min)')
ylabel('Concentration (mg/L)')
title('Antipyrene Continuous')
Select = -1; % Setting for Bolus
subplot(2,1,2)
sim('Lab3AP.slx');
plot(out.Aout)
xlabel('Time (min)')
ylabel('Concentration (mg/L)')
title('Antipyrene Bolus')

回答(1 个)

Abhinav Aravindan
Abhinav Aravindan 2024-10-18
编辑:Abhinav Aravindan 2024-10-18
Hi Brooke,
The simulation outputs of the “To Workspace” block is returned as a SimulationOutput object when “Single simulation output” parameter is enabled in “Configuration Parameters” and not in the “Out” variable which is causing the error. You can access the simulation outputs as follows:
simout = sim('Lab3EB.slx');
plot(simout.Eout)
Please refer to the following link and documentation for further detail:
From the code, it appears that the “Select” variable is being changed and the plots are generated. To simplify this operation, you may utilize “Variant Parameters” to reuse block parameters with different values. For more detail on using “Variant Parameters”, you may refer to the documentation below.

类别

Help CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by