How to give an initial value to a variable in simulink "matlab function"
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
The input is "hitin" and the output is "hitout" (on the right-hand side of M function),which is saved as matrix HIT. However, I want to give an initial value to variable,"hitin". i uses "memory" but it has compiling error! If i am right the result of HIT is supposed to be 1 9 9 9 9 .... Hoping somebody can help me.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/159910/image.gif)
0 commentaires
Réponses (1)
Niklas Nylén
le 1 Avr 2014
It looks like the reason for the compile error is that hitout may not be set at all, for example if hitin = -1.
Change the elseif condition to an else condition and the compile error should disappear.
3 commentaires
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!