output of function as a string

52 Ansichten (letzte 30 Tage)
Tor Fredrik Hove
Tor Fredrik Hove am 31 Okt. 2011
Bearbeitet: Walter Roberson am 7 Apr. 2021
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?

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by