MATLAB Answers

Meaning of the following: function [y1,...yn] = input()

2 views (last 30 days)
Jesse Finnell
Jesse Finnell on 14 Apr 2020
Edited: Jim Riggs on 14 Apr 2020
I have inherited a script that is used in an application that has something like in the title. I and in my journey to understand everything it does I came across a function without outputs and an empyt set of inputs. What is the meaning syntax wise of the emtpy ()?
function [e,eSheets, N,all,membrane_curve,orifice_curve,correctedloss,design_flow,diffperori,units,elevation_tolerance,epsilon,pausetime,...
equivalent_length,active_area,diameter,absolute_roughness,temp,depth,header,correction_factor,bypassed]=input()
I can't find any reasonable answers online on what the meaning of an empty set of parentheses are.

  0 Comments

Sign in to comment.

Accepted Answer

Jim Riggs
Jim Riggs on 14 Apr 2020
Edited: Jim Riggs on 14 Apr 2020
It simply means that there are no user inputs to this function. The long list of variable names are returned from the function.
One can infer that the function most likely returns a-priori constants, or reads an input file and returns the values, or a combination of both.

  0 Comments

Sign in to comment.

More Answers (1)

Ameer Hamza
Ameer Hamza on 14 Apr 2020
Edited: Ameer Hamza on 14 Apr 2020
Empty parenthesis means that the function does not need any input. Such functions are quite similar to scripts except that they have their own workspace: https://www.mathworks.com/help/matlab/matlab_prog/base-and-function-workspaces.html
There can be several reason why a function does not need any input. For example, you want to write a function to print the current date and also return it as a character array. Such a function will not need any input from the user.
function currentDate = showDate()
currentDate = date;
disp(currentDate);
end
It is also possible for function to not have any input and output. For example,
function showDate()
disp(date);
end
Why your function does not have any input will depend on the purpose for which it was written.

  0 Comments

Sign in to comment.


Translated by