Speed up running Simulink model using sim in MATLAB Grader

조회 수: 2 (최근 30일)
IFM
IFM 2019년 12월 10일
댓글: Cris LaPierre 2022년 4월 22일
I have been using MATLAB Grader to much success, but now I want to get my students to run a simple Simulink model using a script. The script is two blocks (Sine Wave and To Workspace). The Sine Wave has two varaibles defined (amp and freq) in the block parameters. My code is:
% block parameters
amp = 5;
freq = pi;
% Run the model
mySim = sim('mg_sin_wave_variables','StopTime','10');
% Use 'get' function to access the information from simulation saved as mySim
T = mySim.get('tout') ; % Get array of time steps
R = mySim.get('simout'); % Get array of results from To Workspace Block
% Plot results
plot(T,R)
At the moment using Chrome and a good internet connection it takes around 40 seconds to run. This is impressive given its in browser, but I would like to run the simulation for a few cases, which is leading to a few minutes of waiting for the output. Any ideas on how I can speed this up?
I have tried uploading the .slxc file but this doesn't seem to make things faster, I just get a Warning saying:
[Warning: The file containing block diagram 'mg_sin_wave_variables' has been changed on disk since it was loaded. Simulink is unable to reload it automatically because it is the root
model. Close it and reopen it manually.]
[> In solution (line 6)
In run (line 91)
In scoringengine.runScript
In ScoringEngineSharedVariable1 (line 1)
In solutionTest (line 3)]
  댓글 수: 2
Sagar Zade
Sagar Zade 2020년 1월 12일
Hi Isobel,
Did you manage to find a solution? If not then I reccomend that you contact Technical Support - https://www.mathworks.com/support/contact_us.html?s_tid=sp_ban_cs
IFM
IFM 2020년 1월 14일
I did not. Thanks for the prompt. I did contact support who said that Simulik is not officially supported yet.

댓글을 달려면 로그인하십시오.

답변 (1개)

Cris LaPierre
Cris LaPierre 2020년 1월 16일
We actively discourage incorporating Simulink into MATLAB Grader. It is not a supported use-case.
  댓글 수: 2
Cristina Nuevo-Gallardo
Cristina Nuevo-Gallardo 2022년 4월 22일
Dear Cris,
I am also willing to use Simulink models in Matlab Grader. Has there been any progress concerning this?
Thanks.
Cris LaPierre
Cris LaPierre 2022년 4월 22일
It is certainly possible to run some Simulink models from within Grader using the sim command, as the OP showed, but the limitations of Grader remain the same. It can therefore be challenging to design a problem using Simulink that creates a positive learning experience for your students and that can be graded within the execution time limit.

댓글을 달려면 로그인하십시오.

커뮤니티

더 많은 답변 보기:  원격 교육 커뮤니티

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by