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

조회 수: 1 (최근 30일)
Jesse Finnell
Jesse Finnell 2020년 4월 14일
편집: Jim Riggs 2020년 4월 14일
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.

채택된 답변

Jim Riggs
Jim Riggs 2020년 4월 14일
편집: Jim Riggs 2020년 4월 14일
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.

추가 답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 4월 14일
편집: Ameer Hamza 2020년 4월 14일
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.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by