I am wondering if this a no output no input function. If it is not what type of function is it?
41 次查看(过去 30 天)
显示 更早的评论
%Lunch
function Lunch
imread('Lunchmenu.jpg');
imshow('Lunchmenu.jpg');
0 个评论
回答(3 个)
DGM
2021-4-14
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:
imread('Lunchmenu.jpg');
0 个评论
Adam Danz
2021-4-14
编辑:Adam Danz
2021-4-14
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');
set(figs,'visible','on')
end
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.
0 个评论
Abdul Basith Ashraf
2021-4-14
Its basically a script.
It is as good as having a file named "Lunch.m" having the two lines:
imread('Lunchmenu.jpg');
imshow('Lunchmenu.jpg');
And you call
Lunch
in the main code
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!