How to make Display block show values while running sim 'outputs' command
3 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
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
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!