DISPARRAY

版本 1.0.0.0 (2.7 KB) 作者: Marco Cococcioni
Displays vectors, matrices and 3d-arrays using custom data formats, elements separators and brackets
1.1K 次下载
更新时间 2006/4/28

查看许可证

function row = disparray(array, format, separator, brackets_type)
% DISPARRAY - Displays arrays using a custom format
%
% This function displays scalars, one-dimentional arrays (vectors),
% two-dimentional arrays (matrices) and three-dimenational arrays,
% using customized format, elements separator and brackets type
%
% INPUTS:
% array: a scalar, a vector, a matrix or a 3D-array
% format: the format for each element, usign the sprintf syntax
% (Type ''help sprintf'' for more help on supported formats)
% separator: separation character or string ( ' ', ', ', '\t', ...)
% brackets_type: type of brackets, if specified {'[','(','{','',' '}
% OUTPUT:
% row: if present, row will contain the array in string format,
% ready to be displayed using disp(sprintf('%s',row)).
% If it is not present (nargout == 0), its content will be displayed,
% and then its content will be cleared.
%
% % Examples:
% clc;
% disp('Scalar (the value will be rounded!):');
% disparray(3.1416, '%.3f', ', ', '[');
% disp('Row vector:');
% disparray(rand(1,6), '%.2f', ', ', '[');
% disp('Column vector:');
% disparray(rand(7,1), '%.2f', ', ', '[');
% disp('Two-dimentional double vector:');
% disparray(randn(3,6), '%.3f', ' ', '[');
% disp('Two-dimentional integer array with zero filling:');
% disparray([1 2 3; 4 5 6],'%04d','\t', '{')
% disp('Two-dimentional double array with forced sign:');
% disparray(randn(5,6),'%+.2f',' ', '(')
% disp('Three-dimentional double array with forced sign:');
% disparray(randn(3,2,4),'%+.2f',' ', ' ')
% disp('Three-dimentional double array with a singleton dimention:');
% disparray(rand(5,1,3),'%.2f', ', ', '{')
% disp('Three-dimentional double array with two singleton dimentions and its name:');
% array3dwithsingletons = rand(1,1,2);
% disparray(array3dwithsingletons,'%g', ', ', '[')
%
% % See also DISP

引用格式

Marco Cococcioni (2024). DISPARRAY (https://www.mathworks.com/matlabcentral/fileexchange/10820-disparray), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2006a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0.0

Removed a bug when no inputs are given.