output of function as a string

71 visualizaciones (últimos 30 días)
Tor Fredrik Hove
Tor Fredrik Hove el 31 de Oct. de 2011
Editada: Walter Roberson el 7 de Abr. de 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?

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by