newline
创建换行符
说明
c = newline
创建一个换行符。newline
等效于 char(10)
或 sprintf('\n')
。使用 newline
将换行符与字符向量或字符串串联,或在换行符处拆分文本。
示例
在字符向量和字符串中添加换行符
使用 newline
创建一个换行符,并将它与字符向量串联。
chr = 'Whose woods these are I think I know.'; chr = [chr newline 'His house is in the village though']
chr = 'Whose woods these are I think I know. His house is in the village though'
尽管 chr
显示为两行,但 chr
是一个 1×73 字符向量,其中包含两个句子,由换行符分隔。
创建一个换行符。然后使用 +
将该换行符和更多文本串联到字符串的末尾。
str = "In Xanadu did Kubla Khan"; str = str + newline + "A stately pleasure-dome decree"
str = "In Xanadu did Kubla Khan A stately pleasure-dome decree"
尽管 str
显示为两行,但 str
是一个 1×1 字符串。
提示
newline
函数不会返回回车符。回车等效于char(13)
或sprintf('\r')
。
扩展功能
C/C++ 代码生成
使用 MATLAB® Coder™ 生成 C 代码和 C++ 代码。
版本历史记录
在 R2016b 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)