MATLAB Answers

output of function as a string

225 views (last 30 days)
Tor Fredrik Hove
Tor Fredrik Hove on 31 Oct 2011
Commented: Steven Lord on 8 Apr 2021 at 4:16
function answer=harflertall(a)
if a==50
answer=disp('it''s a tie')
elseif a<50
answer=disp('less than 50')
else
answer=disp('more than 50')
end
can not output be assigned to be a string?
  1 Comment
Jan
Jan on 31 Oct 2011
This is your 27th question. It is time to be familiar with the code formatting as explained in the "Markup help" link on this page.

Sign in to comment.

Accepted Answer

Titus Edelhofer
Titus Edelhofer on 31 Oct 2011
Hi,
yes it can: disp displays the string in the command window. Just write
answer='less than 50'
Titus
  11 Comments
Steven Lord
Steven Lord on 8 Apr 2021 at 4:16
Folks, remember that the community guidelines state that you should not "Chastise newcomers or insult other members". I recommend that everybody take a breath and step away from this discussion for a day or two (at least.) Thanks.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by