How can we get rtwbuild function output in some variable?

Hello,
I need to generate code from simulink model for this i am using following command:
rtwbuild('model_name')
with this command code is generating but i need to check that code is generated or not so i writes following code:
result= rtwbuild('model_name')
if result == 1
disp("Code is generated")
else
disp("Code is not generated")
end
but every successful build control is navigate to else part. and in the case of unsuccessful build control is not passing to if condition. Can anybody please tell me is there any way to check rtwbuild function return value? Thanks,

 Respuesta aceptada

Walter Roberson
Walter Roberson el 14 de Sept. de 2018
rtwbuild does not return 0 or 1.
"It will return a non-empty block handle to an auto-generated S-Function wrapper, if the selected target creates a S-Function block."
so you should be checking isempty() rather than a numeric value.

5 comentarios

Mady J
Mady J el 14 de Sept. de 2018
Editada: Walter Roberson el 14 de Sept. de 2018
Hello Walter Roberson,
Firstly thank you for quick reply. Still i am not ale to correct output:
result_build= rtwbuild(model_name);
temp_value = isempty(result_build);
if temp_value==1
continue;
end
When ever code is not generating or having any problem system get stop at this line : result_build= rtwbuild(model_name); in this case i am not able to perform further operation. I have no. of simulink model and want to generate code of each one by one. If any model have some error then that model should terminate and continue the code generation loop for other models.
The formal syntax description for rtwbuild() implies it cannot return a value when building a model, only when building a subsystem.
Mady J
Mady J el 14 de Sept. de 2018
So, Is there any other way to achieve the desired output. As, i mentioned in my previous comment?
When I look at the code, it looks to me that if the build process encounters an error, then an error is thrown.
If a subsystem is being built and no error occurred, then the output will be the block handle. If a model is being built, and no error occurred, then [] will be output.
There do not appear to be many circumstances under which an error in building a subsystem could result in no error being thrown, but it looks like it could happen if there was an error in S-function post-processing.
Putting this together, it suggests that you use try/catch, and that if no catch occurred and you are building a subsystem then check the return value for non-empty, and that if no catch occurred but you are not building a subsystem that you just assume that no error occurred (because error would have been thrown if there was.)
Mady J
Mady J el 16 de Sept. de 2018
Thank you Walter. Now it's working fine using try catch.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Test Model Components en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 14 de Sept. de 2018

Comentada:

el 16 de Sept. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by