Ques:Regardless of input, output the string 'yes'.

1 view (last 30 days)
my solution:-
function wiferight(in)
fprintf('yes');
end
what is wrong with my solution?.... Cody says its wrong.... but when i runned it on MATLAB, it is running...

Answers (1)

Stephen23
Stephen23 on 10 Jun 2017
Edited: Stephen23 on 10 Jun 2017
Your function does not actually output anything: your function prints some text to the command window, but printing text using fprintf is a totally different thing to returning an output argument.
How to define MATLAB functions with outputs is a very basic MATLAB concept that is explained in the introductory tutorials (these are highly recommended for all beginners):
How to define MATLAB functions with outputs is also clearly explained in the function help:
Instead of guessing how to use MATLAB, beginners should start to read the MATLAB documentation: the documentation tells us all how to use MATLAB.

Categories

Find more on Characters and Strings in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!