What is the meaning of empty parenthesis in Matlab Object Oriented Programming?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Tuncay Eren
am 23 Jun. 2017
Kommentiert: Tuncay Eren
am 23 Jun. 2017
I have been working on OFDM using Object Oriented methadology and in the following code block trying to understand the usage of the functions with empty parenthesis.
In the code the first function with obj in the paranthesis but the others have empty paranthesis. Could you please help how to interpret the empty ones?
classdef OFDM_Signal
properties
...
end
methods
function obj=OFDM_Signal(StructParameters)
....
end
end
methods
function ofdmTransmitter(Obj)
% Source
Obj.genOfdmBits();
% TxBits to symbol conversion (mapper)
Obj.getOfdmData();
......
end
end
end
0 Kommentare
Akzeptierte Antwort
Guillaume
am 23 Jun. 2017
It's the same meaning as for normal functions: it does not mean anything. It's calling the function or method with no arguments and the parenthesis could be omitted.
The only reason for writing the parenthesis is to convey to the reader that you're calling a method of the class instead of accessing a property of the class. I.e. I would write:
a = obj.someproperty;
b = obj.somefuncwithnoargs();
to make clear that someprop is a property and somefuncwithnoargs is a function. It's just a matter of preference. As said the parenthesis are optional.
This may also be a hang up from other languages such as C++, where parenthesis are always required for function calls.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Construct and Work with Object Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!