output of function as a string

51 次查看(过去 30 天)
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?

采纳的回答

Titus Edelhofer
Titus Edelhofer 2011-10-31
Hi,
yes it can: disp displays the string in the command window. Just write
answer='less than 50'
Titus

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by