What does dot (.) do in this code?

1 view (last 30 days)
Sonu
Sonu on 14 Apr 2017
Answered: Image Analyst on 14 Apr 2017
what this code will do?
A.phase
where as A is a struct and phase is a function name. and in other scenario
decompose.amp
where as decompose is a function name while amp is not mentioned in a whole code.
Regards

Answers (1)

Image Analyst
Image Analyst on 14 Apr 2017
I don't think your definitions are correct. If you have A.phase then I don't think A can be a structure and phase be a function.
One possibility is that A is a structure and phase is a "property", not a function.
The other possibility is that A is a "class" , not a structure, and phase is a function , which in object oriented lingo means phase is a "method" of the class called A. Actually, more precisely, (the badly-named) A would either be an "instance of a class" or a "static class". Those are two different concepts. An instance of the class means that you create a new object that is it's own self-contained chunk of memory with properties and associated functions. If the class is a special type of class, a "static" class, you don't need to instantiate a self-contained object but can instead just call the methods as if they were regular old functions. Since you probably don't have any idea what I'm talking about (and I wouldn't if I didn't already know OOP), it might be good if you could find some kind of really basic primer/tutorial on OOP (object oriented programming). I use classes a little bit in MATLAB but not a lot.
If A is a class and you put the cursor on A and type control-D it will take you to the definition of the class which might look like
classdef A
% Summary of this class goes here
% Detailed explanation goes here
% properties
% whatever; % These are variables
% end
% methods(Static) % These are functions
% function result = phase(someInput)
% % code for phase follows.....
% end
methods(Static)
and so on....

Community Treasure Hunt

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

Start Hunting!