To File block with rapid accelerator

조회 수: 5 (최근 30일)
Eduardo
Eduardo 2023년 1월 25일
댓글: Eduardo 2023년 6월 14일
I am trying to deploy a simulink model as an application to perform multiple simulations. See Matlab Example
My model generates an output file using a To File block and I would like to set the output file name using an input parameter of the function executing the simulation.
This has worked perfectly for constant and gain blocks but the FileName parameter of my To File block does not seem affected when I use "setVariable" to give the desired name.
simObject = Simulink.SimulationInput('model');
simObject = simObject.setVariable('fileName','desiredName.mat');
simObject = simulink.compiler.configureForDeployment(simObject);
out = sim(simObject)
What I get instead is a file named "fileName.mat", which is the variable which I want to use as a changing parameter.
Any ideas why it is not working?

채택된 답변

Harshal Ritwik
Harshal Ritwik 2023년 6월 13일
Hi, 
As per my understanding you want to change the file name of the file to which your output file is being saved from the “To File block. Using FileName” in the parameter instead of 'fileName' will work. You can use the file name as you want. The following code snippet may help.
%Code Section
simObject = Simulink.SimulationInput('model');
simObject = simObject.setVariable('FileName','desiredName.mat');
simObject = simulink.compiler.configureForDeployment(simObject);
out = sim(simObject);
Please refer to the following documentation for more information
I hope it helps!
Thanks.
  댓글 수: 1
Eduardo
Eduardo 2023년 6월 14일
ugh such a small thing.....
Thank you :P

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Application Deployment에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by