output of function as a string

76 ビュー (過去 30 日間)
Tor Fredrik Hove
Tor Fredrik Hove 2011 年 10 月 31 日
編集済み: Walter Roberson 2021 年 4 月 7 日
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 Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by