- https://www.mathworks.com/matlabcentral/answers/453940
- https://www.mathworks.com/help/simulink/slref/toworkspace.html
How to use simulink output in matlab for graphs?
조회 수: 14 (최근 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')
댓글 수: 0
답변 (1개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 General Applications에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!