strjust
对齐字符串
说明
示例
右对齐文本
创建字符串数组,其中的一些元素具有尾随空白字符。
str1 = ["Skylab"; "Mir "; "ISS "]
str1 = 3x1 string
"Skylab"
"Mir "
"ISS "
靠右对齐文本。strjust
不会更改第一个元素,因为 "Skylab"
不包含任何空白。
str2 = strjust(str1)
str2 = 3x1 string
"Skylab"
" Mir"
" ISS"
居中对齐文本
创建字符向量元胞数组。有些字符向量具有前导和尾随空白字符。
C1 = {'Euler '; 'Fibonacci'; ' Gauss'}
C1 = 3x1 cell
{'Euler '}
{'Fibonacci'}
{' Gauss'}
居中对齐文本。如果一段文本具有前导或尾随空白,或同时具有前导和尾随空白,则 strjust
将文本调整为具有相等数量的前导和尾随空白字符。如果文本段没有前导或尾随空白,strjust
将不会更改该文本段。
C2 = strjust(C1,'center')
C2 = 3x1 cell
{' Euler '}
{'Fibonacci'}
{' Gauss '}
输入参数
str
— 输入文本
字符数组 | 字符向量元胞数组 | 字符串数组
输入文本,指定为字符数组、字符向量元胞数组或字符串数组。
side
— 文本对齐方式
'right'
(默认) | 'left'
| 'center'
文本的对齐方式,指定为 'left'
、'right'
或 'center'
对齐。默认行为是右对齐文本。
扩展功能
C/C++ 代码生成
使用 MATLAB® Coder™ 生成 C 代码和 C++ 代码。
用法说明和限制:
输入文本必须是字符串标量或字符向量。
生成的代码以 1×0 字符数组的形式返回空输出。
基于线程的环境
使用 MATLAB® backgroundPool
在后台运行代码或使用 Parallel Computing Toolbox™ ThreadPool
加快代码运行速度。
此函数完全支持基于线程的环境。有关详细信息,请参阅Run MATLAB Functions in Thread-Based Environment。
版本历史记录
在 R2006a 之前推出
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)