output of function as a string

조회 수: 79 (최근 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 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