[Simulink] How to write Values to Workspace when a Zero Crossing Occurs

2 views (last 30 days)
I have a "continuous" simulation of an object falling into the sea. My customer wants output of ~80 parameters at (say) 0.1 second timesteps, including the timestep AFTER impact. - Which I have successfully done by writing to the workspace with the sample time =0.1, AND a memory block followed by a zero crossing detection in the downs direction to terminate ~0.1 seconds late. HOWEVER, my customer understandably also wants to know the ~80 parameters at the moment of surface impact, even though this is between the timesteps, which I could do by stopping at the sea surface crossing. So far I can see how to do one or the other, but not both in the same simulation. Suggestions? I don't mind having to rearrange the rows of data in Matlab, but I can't see how to extract the additional data at just the zero crossing, and the run time is bad enough without having to run at milliseconds then decimating. I'm new to Simulink, and have not yet tried any blocks that only activate on an "event", except the Stop event. Thanks

Answers (1)

Bo Yuan
Bo Yuan on 3 Aug 2017
Based on my understanding, you are looking to log simulation data at the zero crossing point including the minor steps of integration. You can refer to this link and try this block for minor step logging.

Categories

Find more on General Applications in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!