how to implement while loop with time condition in matlab?
tin is an argument to your function, as a result, it cannot change value during a call to the function, and the condition for loop termination cannot be satisfied, unless it was from the very beginning.
You are going to have rethink the whole design of your program such that it can actually become aware of changes in the value of whatever tin represents.
Probably you want the while loop to wrap whatever obtains the value, if you then still use a function at all, you would call it once per iteration of the while loop (it's possible that however this is hooked up in your software package would already effectively do that by continuously re-executing your function - ie, the mistake may be having your own while loop at all)
The same concern would go for your other input, Vout as well.
I'd suggest you take a step back and find a simpler example of a function that plugs into this sort of simulation system, and take time to understand how it operates on time-varying inputs.  Once you really understand how that works, you can re-implement the logic you need in a way compatible with this framework.