matlab编程
function y=Testlab(n) if n<=10 fprintf('ten or less \n'); elseif n<20 fprintf('greater than ten but less than twenty \n') elseif n<30 fprintf('twenty or greater but less than thirty \n') else fprintf('thirty or greater \n') end \n'作用是什么,为什么
function y=Testlab(n) if n<=10 fprintf('ten or less \n'); elseif n<20 fprintf('greater than ten but less than twenty \n') elseif n<30 fprintf('twenty or greater but less than thirty \n') else fprintf('thirty or greater \n') end \n'作用是什么,为什么
答案:在fprintf与sprintf的格式化输出中,'\n'相当于一个换行符,也就是下一个fprintf输出的字符串会另起一行。
你可以在matlab命令中输入doc sprintf查看说明文档,里面有:
\\ Backslash
\a Alarm
\b Backspace
\f Form feed
\n New line
\r Carriage return
\t Horizontal tab
\v Vertical tab
\xN Hexadecimal number, N
\N Octal number, N
其他:在输出时,用于换行,让下一次输出内容在下一行显示,类似word中你按下Enter键的的作用
上一个:matlab 编程问题,总是报错,问题不难但就是解决不了。在线求解
下一个:matlab7.0和matlab7.10.0有什么差别?编程时应该注意什么?