What is the meaning of empty parenthesis in Matlab Object Oriented Programming?

11 views (last 30 days)
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

Accepted Answer

Guillaume
Guillaume on 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.

More Answers (0)

Categories

Find more on Methods in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!