How to make Display block show values while running sim 'outputs' command

조회 수: 9 (최근 30일)
Augusto Dufloth
Augusto Dufloth 2022년 1월 21일
답변: Moksh 2023년 11월 8일
I have a simulink model with a lot of displays attached to wires that I am calling through a script. At first I check if the model is compiled. If not, I run the following command
feval(bdroot,[],[],[],'compile');
after that I build my input arrays, called 'ut' and then I evaluate my model to get the outputs
yt = feval(bdroot,0,[],ut,'outputs');
And I correctly get my outputs at 'yt' and I run the 'term' command
My problem is that when I look into the model, none of my Displays show a value different from zero. When the model is compiled, they don't show any value. After I run the 'outputs', they show zero. They only show values different from zero if I run a simulation in time.
Is there any way to make them show the value when I evaluate the model through the 'outputs' command?
Thanks

답변 (1개)

Moksh
Moksh 2023년 11월 8일
Hi Augusto,
I understand that you are trying to capture the display values, but the model is not showing changes when it is compiled. This may be occurring because the model might be updating the values during a simulation run and not during the model evaluation using the “feval” command.
You can try using the “sim” command in MATLAB which allows to simulate the model and captures outputs without opening the Simulink interface.
Here is an example pseudocode for this:
% Check if the model is compiled
if ~isdeployed
% Compile the model
feval(bdroot,[],[],[],'compile');
end
% Build input arrays
ut = ... % Your input array
% Simulate the model and capture the outputs
simOut = sim(bdroot);
% Access the outputs
yt = simOut.get('yt');
% Display the outputs
disp(yt);
For more information about the “sim” function please refer to the following MATLAB documentation:
Hope this information helps resolve the issue.
Best Regards,
Moksh Aggarwal

카테고리

Help CenterFile Exchange에서 Manual Performance Optimization에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by