File Exchange

image thumbnail

DISPARRAY

version 1.0.0.0 (2.66 KB) by Marco Cococcioni
Displays vectors, matrices and 3d-arrays using custom data formats, elements separators and brackets

1.1K Downloads

Updated 28 Apr 2006

View License

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 (2021). DISPARRAY (https://www.mathworks.com/matlabcentral/fileexchange/10820-disparray), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2006a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!