Raise warning from simulink block mask initialization?

Hi,
From the mask initialization tab I am trying to check the value of a variable. If var == 999 I want to raise a warning. i.e. I want a warning to be shown in the Matlab command line. But using warning('message') or error('message') does nothing. Any ideas on how to do this? Thanks!

Respuestas (1)

Sreeram Mohan
Sreeram Mohan el 19 de Sept. de 2014
Hi Carlos,
Can you try using evalin('base', 'warning(''message'')') to see if that helps ?
--sreeram mohan

3 comentarios

Carlos
Carlos el 19 de Sept. de 2014
Editada: Walter Roberson el 12 de Sept. de 2024
Thanks for the suggestion Sreeram, but that did not work. For sending error messages this works:
try
if var == 999
error('error message')
end
catch exception
throwAsCaller(exception)
end
but I still don't ave a solution for warnings.
Carlos
Carlos el 19 de Sept. de 2014
Actually that works Sreeram, but not as well as I would like. If I write the evalin('base','warning(''meassage'')') command in the mask initialization it works perfectly.
But to keep the question simple I had omitted some details. I need to call the same error checking from 11 different blocks in my library. So ideally I'd like this little piece of code to be a function (class method actually). If I put the evalin(...) in a class method and then call that method from the block initialization then it does not work.
I'd prefer it to be a class method so that I do not have to change it in 11 different places when I want to make a change.
Any idea on how to do this?
Thanks for the help!
- Carlos
Can you try an feval combination with evalin ?
For example evalin('base', 'feval(''warning_function_class'', ''parameters'')')
Just a thought !
Sreeram Mohan

Iniciar sesión para comentar.

Productos

Preguntada:

el 18 de Sept. de 2014

Editada:

el 12 de Sept. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by