How to use simulink output in matlab for graphs?

8 Ansichten (letzte 30 Tage)
Brooke
Brooke am 17 Okt. 2024
Bearbeitet: Abhinav Aravindan am 18 Okt. 2024
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')

Antworten (1)

Abhinav Aravindan
Abhinav Aravindan am 18 Okt. 2024
Bearbeitet: Abhinav Aravindan am 18 Okt. 2024
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.

Kategorien

Mehr zu Programmatic Model Editing finden Sie in Help Center und File Exchange

Produkte


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by