MATLAB Answers

Single instance of class

64 views (last 30 days)
Hello all! I have just started learning MATLAB and am exploring the OOPS concepts in it. Can someone guide me how to create a class and limit it with only one instance? Also can someone tell me where one can use it


Sign in to comment.

Accepted Answer

Chirag Nighut
Chirag Nighut on 4 Jul 2019
In order to limit a single instance of a class you can use the persistent variables. Such type of classes are called Singleton Class. Such classes can be used
  1. When you wish to create a single client for connecting a server.
  2. Handle for a GUI
Following link should help you understand the singleton class and also its implementation:


Sign in to comment.

More Answers (0)

Sign in to answer this question.