DISPARRAY
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
Plattform-Kompatibilität
Windows macOS LinuxKategorien
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Live Editor erkunden
Erstellen Sie Skripte mit Code, Ausgabe und formatiertem Text in einem einzigen ausführbaren Dokument.
Version | Veröffentlicht | Versionshinweise | |
---|---|---|---|
1.0.0.0 | Removed a bug when no inputs are given. |