Hi,
You might want to look at the example in the documentation.
Also, there are two file exchange repositories that might make sense to your problem:
I hope it helps!
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!