Simulink: how to initialize the first state of an output function

15 views (last 30 days)
Hello everyone,
I guess my issue is quite simple but i didn't manage to find any good answer after looking for it.
I am using a matlab function into a simulink matlab model. This function is simple, it calculates the angle from a sinus and a cosinus thanks to atan function:
function atan_result = atan_calculation(sin_signal, cos_signal)
atan_result = atan(sin_signal/cos_signal) ;
end
My model runs but does not give any result because there is no value at the first step at the output of this matlab function, while there is discrete input values. So i don't understand why but maybe this is the way a matlab function works ?
Anyway, can someone explain me how to fix it? by modifying the matlab function code, adding a simulink block, or configuring sometthing in the callbacks function of the model properties maybe?
Thank you in advance,

Answers (1)

Ninja
Ninja on 12 Feb 2019
ok, I just found it, it is just that atan function at start can process the division calculation 0 / 0, so i need to take into account this case.

Categories

Find more on Event Functions in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!