DISPARRAY

Displays vectors, matrices and 3d-arrays using custom data formats, elements separators and brackets
1,1K Downloads
Aktualisiert 28. Apr 2006

Lizenz anzeigen

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

Zitieren als

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

Kompatibilität der MATLAB-Version
Erstellt mit R2006a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Veröffentlicht Versionshinweise
1.0.0.0

Removed a bug when no inputs are given.