MATLAB Answers

I am wondering if this a no output no input function. If it is not what type of function is it?

17 views (last 30 days)
Andrew Mays
Andrew Mays on 14 Apr 2021 at 2:38
Answered: Abdul Basith Ashraf on 14 Apr 2021 at 4:10
function Lunch

Answers (3)

DGM on 14 Apr 2021 at 2:45
It certainly doesn't have any input or output arguments, but reading the file with imread() is redundant if using that syntax with imshow(). This line does nothing:

Adam Danz
Adam Danz on 14 Apr 2021 at 2:50
Edited: Adam Danz on 14 Apr 2021 at 2:51
Functions do not have to have inputs or outputs.
For example, this function below searches for invisible figures and makes them visible,
function invisibleFigToggle()
figs = findall(0,'type','figure','visible','off');
Your function reads an image and displays it in a the current figure or creates the current figure.
It's a poorly written function, though.
  • What if 'Lunchmenu.jpg' doesn't exist?
  • What if an unrelated figure already exists?
  • The function name is really bad and does not describe what the function does.
  • It's not clear why those two lines needs to be within a function.

Abdul Basith Ashraf
Abdul Basith Ashraf on 14 Apr 2021 at 4:10
Its basically a script.
It is as good as having a file named "Lunch.m" having the two lines:
And you call
in the main code


Community Treasure Hunt

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

Start Hunting!