Force arrays to print to screen without multiplier

I work with a number of arrays that I print to the screen for visual inspection. An example is below. I hate the scaling factor (1.0e+03). It is absolutely useless and interferes with visual inspection of data for debugging and anlysis. How do I force Matlab to display all arrays without the scaling factor?
>>vProduct = cross(v1com, v2com, 2)
vProduct =
1.0e+03 *
0.0048 0.0076 3.1440
-0.0049 0.0076 3.9840
-0.0017 0.0076 -0.6840
-0.0049 -0.0048 -4.5480
-0.0017 -0.0048 -0.2940
-0.0017 0.0049 -1.3620

Answers (2)

vProduct = 1.0e+03 *[
0.0048 0.0076 3.1440
-0.0049 0.0076 3.9840
-0.0017 0.0076 -0.6840
-0.0049 -0.0048 -4.5480
-0.0017 -0.0048 -0.2940
-0.0017 0.0049 -1.3620]
vProduct = 6×3
1.0e+03 * 0.0048 0.0076 3.1440 -0.0049 0.0076 3.9840 -0.0017 0.0076 -0.6840 -0.0049 -0.0048 -4.5480 -0.0017 -0.0048 -0.2940 -0.0017 0.0049 -1.3620
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
format shorte
vProduct
vProduct = 6×3
1.0e+00 * 4.8000e+00 7.6000e+00 3.1440e+03 -4.9000e+00 7.6000e+00 3.9840e+03 -1.7000e+00 7.6000e+00 -6.8400e+02 -4.9000e+00 -4.8000e+00 -4.5480e+03 -1.7000e+00 -4.8000e+00 -2.9400e+02 -1.7000e+00 4.9000e+00 -1.3620e+03
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
format longe
vProduct
vProduct = 6×3
1.0e+00 * 4.800000000000000e+00 7.600000000000000e+00 3.144000000000000e+03 -4.899999999999999e+00 7.600000000000000e+00 3.984000000000000e+03 -1.700000000000000e+00 7.600000000000000e+00 -6.840000000000000e+02 -4.899999999999999e+00 -4.800000000000000e+00 -4.548000000000000e+03 -1.700000000000000e+00 -4.800000000000000e+00 -2.940000000000000e+02 -1.700000000000000e+00 4.899999999999999e+00 -1.362000000000000e+03
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
format bank
vProduct
vProduct = 6×3
1.0e+00 * 4.80 7.60 3144.00 -4.90 7.60 3984.00 -1.70 7.60 -684.00 -4.90 -4.80 -4548.00 -1.70 -4.80 -294.00 -1.70 4.90 -1362.00
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
format shortG
vProduct
vProduct = 6×3
1.0e+00 * 4.8 7.6 3144 -4.9 7.6 3984 -1.7 7.6 -684 -4.9 -4.8 -4548 -1.7 -4.8 -294 -1.7 4.9 -1362
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
It's apparently a new "feature" that the command window displays the "1.00E+00" multiplier even when it is 1; that didn't use to happen. I also think that is annoying and the prior behavior would be preferred.
If one wants a specific format other than the various options given with the format command, one has to write an output format specification and use fprintf which entails counting columns and building the appropriate number of fields and locating the linefeeds. Here's a place where my complaint since the beginnings of MATLAB that the C-style i/o was chosen over Fortran FORMAT really shows up in the inconvenience.
function write2Darray(x,wide,ndec)
% simple-minded function to display array at given precision, width
[r,c]=size(x);
fmt=sprintf('%%%d.%df',wide,ndec); % the single variable format first '%10.3F', e.g
fmt=[repmat(fmt,1,c) '\n']; % repeat to match array width, add newline
fprintf(fmt,x.') % print w/ format; remember transpose
end
write2Darray(vProduct,10,3)
4.800 7.600 3144.000 -4.900 7.600 3984.000 -1.700 7.600 -684.000 -4.900 -4.800 -4548.000 -1.700 -4.800 -294.000 -1.700 4.900 -1362.000
One can get much more elaborate, of course including passing the format type or the width and/or precision by column as vectors.
Before Mathworks made it essentially impossible to add a Fortran compiler I had a mex file that used the Fortran FORMAT facility to do this kind of thing to be able to avoid the repmat construct since FORMAT is defined such that a field repeat multiplier is possible.
ADDENDUM
The problem with the above approach is, of course, one has to manually call it unless bury it inside other functions in which case the semicolon feature doesn't help to turn it off. It's an area I complained about in the most early days that there's no user ability for any finer control over the command output than the ever-existing set of format choices provided.
It seems like I recall a thread a few years ago of a similar complaint/wish and @Walter Roberson discussed some of what would take to override the builtin functionality and it would be, of course, exceedingly difficult if not impossible.

1 Comment

May be feasible to write one's own subclass of double, et., al., for the sole purpose of redefining the disp method, and suffer from any other headaches such an approach might cause.

Sign in to comment.

Experiment with the format function.
Example --
vProduct = 1.0e+03 *[0.0048 0.0076 3.1440
-0.0049 0.0076 3.9840
-0.0017 0.0076 -0.6840
-0.0049 -0.0048 -4.5480
-0.0017 -0.0048 -0.2940
-0.0017 0.0049 -1.3620];
vProduct
vProduct = 6×3
1.0e+03 * 0.0048 0.0076 3.1440 -0.0049 0.0076 3.9840 -0.0017 0.0076 -0.6840 -0.0049 -0.0048 -4.5480 -0.0017 -0.0048 -0.2940 -0.0017 0.0049 -1.3620
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
format shortG
vProduct
vProduct = 6×3
1.0e+00 * 4.8 7.6 3144 -4.9 7.6 3984 -1.7 7.6 -684 -4.9 -4.8 -4548 -1.7 -4.8 -294 -1.7 4.9 -1362
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
●
There may be more precision in your data than what you posted, so it may appear to be different from what is posted here. It should look similar.
.

6 Comments

Note that at the MATLAB command window, format shorte, format longe, format shortg, format longg, all do not display the leading multiplier string. The leading multipler string shows up here in MATLAB Answers, but not in desktop for the command window and not for desktop for LiveScript
This statement is false. On 2024a MATLAB running in text interface, the leading multiplier string DOES show up every time.
vProduct = 1.0e+03 *[0.0048 0.0076 3.1440
-0.0049 0.0076 3.9840
-0.0017 0.0076 -0.6840
-0.0049 -0.0048 -4.5480
-0.0017 -0.0048 -0.2940
-0.0017 0.0049 -1.3620];
format long g
vProduct
vProduct =
4.8 7.6 3144
-4.9 7.6 3984
-1.7 7.6 -684
-4.9 -4.8 -4548
-1.7 -4.8 -294
-1.7 4.9 -1362
format short
vProduct
vProduct =
1.0e+03 *
0.0048 0.0076 3.1440
-0.0049 0.0076 3.9840
-0.0017 0.0076 -0.6840
-0.0049 -0.0048 -4.5480
-0.0017 -0.0048 -0.2940
-0.0017 0.0049 -1.3620
MATLAB Version: 24.1.0.2628055 (R2024a) Update 4
"The leading multipler string shows up here in MATLAB Answers,...."
That I noticed, Walter. Why?
ver
------------------------------------------------------------------------------------------------- MATLAB Version: 25.2.0.2998904 (R2025b) MATLAB License Number: 40912989 Operating System: Linux 6.8.0-1019-aws #21~22.04.1-Ubuntu SMP Thu Nov 7 17:33:30 UTC 2024 x86_64 Java Version: Java 1.8.0_292-b10 with AdoptOpenJDK OpenJDK 64-Bit Server VM mixed mode ------------------------------------------------------------------------------------------------- MATLAB Version 25.2 (R2025b) Simulink Version 25.2 (R2025b) 5G Toolbox Version 25.2 (R2025b) Aerospace Blockset Version 25.2 (R2025b) Aerospace Toolbox Version 25.2 (R2025b) Antenna Toolbox Version 25.2 (R2025b) Audio Toolbox Version 25.2 (R2025b) Automated Driving Toolbox Version 25.2 (R2025b) Bioinformatics Toolbox Version 25.2 (R2025b) Bluetooth Toolbox Version 25.2 (R2025b) Communications Toolbox Version 25.2 (R2025b) Computer Vision Toolbox Version 25.2 (R2025b) Control System Toolbox Version 25.2 (R2025b) Curve Fitting Toolbox Version 25.2 (R2025b) DO Qualification Kit Version 25.2 (R2025b) DSP System Toolbox Version 25.2 (R2025b) Database Toolbox Version 25.2 (R2025b) Datafeed Toolbox Version 25.2 (R2025b) Deep Learning Toolbox Version 25.2 (R2025b) Econometrics Toolbox Version 25.2 (R2025b) Embedded Coder Version 25.2 (R2025b) Financial Instruments Toolbox Version 25.2 (R2025b) Financial Toolbox Version 25.2 (R2025b) Fixed-Point Designer Version 25.2 (R2025b) Fuzzy Logic Toolbox Version 25.2 (R2025b) Global Optimization Toolbox Version 25.2 (R2025b) HDL Coder Version 25.2 (R2025b) HDL Verifier Version 25.2 (R2025b) IEC Certification Kit Version 25.2 (R2025b) Image Acquisition Toolbox Version 25.2 (R2025b) Image Processing Toolbox Version 25.2 (R2025b) Industrial Communication Toolbox Version 25.2 (R2025b) Instrument Control Toolbox Version 25.2 (R2025b) LTE Toolbox Version 25.2 (R2025b) MATLAB Coder Version 25.2 (R2025b) MATLAB Compiler Version 25.2 (R2025b) MATLAB Compiler SDK Version 25.2 (R2025b) MATLAB Report Generator Version 25.2 (R2025b) Mapping Toolbox Version 25.2 (R2025b) Medical Imaging Toolbox Version 25.2 (R2025b) Mixed-Signal Blockset Version 25.2 (R2025b) Model Predictive Control Toolbox Version 25.2 (R2025b) Model-Based Calibration Toolbox Version 25.2 (R2025b) Navigation Toolbox Version 25.2 (R2025b) Optimization Toolbox Version 25.2 (R2025b) Parallel Computing Toolbox Version 25.2 (R2025b) Partial Differential Equation Toolbox Version 25.2 (R2025b) Phased Array System Toolbox Version 25.2 (R2025b) Powertrain Blockset Version 25.2 (R2025b) Predictive Maintenance Toolbox Version 25.2 (R2025b) RF Blockset Version 25.2 (R2025b) RF Toolbox Version 25.2 (R2025b) Radar Toolbox Version 25.2 (R2025b) Requirements Toolbox Version 25.2 (R2025b) Risk Management Toolbox Version 25.2 (R2025b) Robotics System Toolbox Version 25.2 (R2025b) Robust Control Toolbox Version 25.2 (R2025b) Sensor Fusion and Tracking Toolbox Version 25.2 (R2025b) SerDes Toolbox Version 25.2 (R2025b) Signal Processing Toolbox Version 25.2 (R2025b) SimBiology Version 25.2 (R2025b) SimEvents Version 25.2 (R2025b) Simscape Version 25.2 (R2025b) Simscape Driveline Version 25.2 (R2025b) Simscape Electrical Version 25.2 (R2025b) Simscape Fluids Version 25.2 (R2025b) Simscape Multibody Version 25.2 (R2025b) Simulink 3D Animation Version 25.2 (R2025b) Simulink Check Version 25.2 (R2025b) Simulink Code Inspector Version 25.2 (R2025b) Simulink Coder Version 25.2 (R2025b) Simulink Control Design Version 25.2 (R2025b) Simulink Coverage Version 25.2 (R2025b) Simulink Design Optimization Version 25.2 (R2025b) Simulink Design Verifier Version 25.2 (R2025b) Simulink Desktop Real-Time Version 25.2 (R2025b) Simulink PLC Coder Version 25.2 (R2025b) Simulink Real-Time Version 25.2 (R2025b) Simulink Report Generator Version 25.2 (R2025b) Simulink Test Version 25.2 (R2025b) Stateflow Version 25.2 (R2025b) Statistics and Machine Learning Toolbox Version 25.2 (R2025b) Symbolic Math Toolbox Version 25.2 (R2025b) System Identification Toolbox Version 25.2 (R2025b) Text Analytics Toolbox Version 25.2 (R2025b) Vehicle Dynamics Blockset Version 25.2 (R2025b) Vehicle Network Toolbox Version 25.2 (R2025b) Vision HDL Toolbox Version 25.2 (R2025b) WLAN Toolbox Version 25.2 (R2025b) Wavelet Toolbox Version 25.2 (R2025b) Wireless HDL Toolbox Version 25.2 (R2025b)
is that yet another "feature" in R2025a/b? Very annoying, if so...
It is not a feature of R2025a / R2025b. I tested on R2025b before posting. It is a feature of MATLAB Answers (and, I suspect, MATLAB Online)
Wonder why make it different...good to not muck up real version.

Sign in to comment.

Products

Release

R2024b

Asked:

on 19 Sep 2025

Commented:

dpb
on 20 Sep 2025

Community Treasure Hunt

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

Start Hunting!