Hello everybody, there is just one simple question that comes across my mind and I can not figure it by myself, so I would like to put it here and see your understanding or opinion about it.
The question is: is matlab basic variable such as double, char object?
When I try to do some object operations such as getting its properties or the methods it can do, I got response which says that those variables are not class, but when I do the whos, it shows that those variables have class. How can I understand that?
Thanks for your opinions.

 Réponse acceptée

James Tursa
James Tursa le 16 Avr 2020

0 votes

All variables have a "class". But not all variables are objects from an OOP class defined with classdef. I think what you are trying to do is treat regular objects like doubles and char as if they are objects from an OOP class defined with classdef, which they aren't.

3 commentaires

Qi Liu
Qi Liu le 16 Avr 2020
Thanks for sharing your opinion.
You mean that the basic variable types in MATLAB such as double, char, cell. Once a variable in one of these types is created, it is not created using the regular way which we use to create our own objects (using the classdef). These variables have their own way to be created which is already specified by MATLAB.
This means MATLAB treats its own variable types and the types the user defines in 2 different ways.
James Tursa
James Tursa le 16 Avr 2020
Yes, variables created as one of the pre-defined classes such as double and char have their own pre-defined methods of creation and usage. They are not OOP classdef objects.
Qi Liu
Qi Liu le 17 Avr 2020
Thanks a lot.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by