STRPAD String Pad for Matlab

버전 1.0.0.0 (2.07 KB) 작성자: Gavin
Simple function for padding strings with any number of char either at the start or the end
다운로드 수: 528
업데이트 날짜: 2012/5/18

라이선스 보기

This has probably been created by other users, it can also be done easily with printf, but it is not core Matlab (that I know of). Since I use it as is in some of my other libraries so I was asked to add it here.

--------------------
__ strpad __
--------------------

A simple function for padding out strings with a single char.
I wrote for a serial driver which required fixed string sizes

--------------------
__ Author __
Gavin Paul
Gavin.Paul[at]gmail.com
12th April 2012
Update: 18th May 2012 (added the missing strpad.m file)

--------------------
__ Files __

--------------------

strpad.m
README.txt

--------------------
__ Instructions __
--------------------
1)
- type "help strpad" into matlab command line

----------- OUTPUT FROM HELP -----------

STRPAD pads a string with any number of char either at the start or the
end

% To pad the string ABC with zeros ('0') at the front to make it 8
% characters long ('i.e. 00000ABC')
strpad('ABC',8,'pre','0')

% To pad the string Hello with zeros ('Q') at the end to make it 14
% characters long ('i.e. HelloQQQQQQQQQ')
strpad('Hello',14,'post','Q')

% To pad the String 101010 with ones ('1') so that it is 16 characters
% long (i.e. '1111111111101010'). Note by default
strpad('101010',16)

% Error cases:
% - Not passing in a string

% Warning cases:
% - Not passing in the required number of character
% -- Default: return the string passed in
% - Passing in a string which is longer than the character requested
% -- Default: return the string passed in
% - Passing in more than 1 padding character
% -- Default: is to pad with '0's

인용 양식

Gavin (2024). STRPAD String Pad for Matlab (https://www.mathworks.com/matlabcentral/fileexchange/36766-strpad-string-pad-for-matlab), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2010a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Characters and Strings에 대해 자세히 알아보기
도움

도움 준 파일: strpad

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0