how to use matlab function in simulink when there are several while loops in function?

I was trying to execute a matlab function in simulink and i found below error.
Errors occurred during parsing of MATLAB function 'MATLAB Function'. I tried to debug it myself and found that if i remove While loop from it then every thing works simply fine.
One more error appeared and that was Variable 'HC' is undefined on some execution paths. the variable HC get its value in a while loop only and some execution path it is coming as undefined. So is there any problem if a loop is executed through a matlab function in simulink or the problem is something else? whats the solution for this?
I am not able understand this problem and while loop is inevitable part of that code. please suggest the solution so that i can run this code as part of simulink simulation.

Answers (1)

Just assign some value to the variable before the while loop starts.

Categories

Find more on Simulink in Help Center and File Exchange

Tags

No tags entered yet.

Asked:

on 12 Dec 2012

Community Treasure Hunt

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

Start Hunting!