You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
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
Cite As
Marco Cococcioni (2026). DISPARRAY (https://au.mathworks.com/matlabcentral/fileexchange/10820-disparray), MATLAB Central File Exchange. Retrieved .
General Information
- Version 1.0.0.0 (2.66 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
| Version | Published | Release Notes | Action |
|---|---|---|---|
| 1.0.0.0 | Removed a bug when no inputs are given. |
