How to give an initial value to a variable in simulink "matlab function"
5 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Niklas Nylén
2014-4-1
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!