How can I change the format to NOT display a matrix like this:
1.0e+003 *
3.1251 0 0 0 0 0 0 0 0 0
0 3.1251 0 0 0 0 0 0 0 0
0 0 3.1251 0 0 0 0 0 0 0
0 0 0 3.1251 0 0 0 0 0 0
0 0 0 0 3.1251 0 0 0 0 0
0 0 0 0 0 3.1251 0 0 0 0
0 0 0 0 0 0 3.1251 0 0 0
0 0 0 0 0 0 0 3.1251 0 0
0 0 0 0 0 0 0 0 3.1251 0
0 0 0 0 0 0 0 0 0 3.1251
but instead to include the 1.0e+003
into every double so that the matrix looks like 3125
along the diagonal?
Indexing with Element Positions For example, to access a single element of a matrix, specify the row number followed by the column number of the element. e is the element in the 3,2 position (third row, second column) of A . You can also reference multiple elements at a time by specifying their indices in a vector.
Display Multiple Variables on Same Line Here are three ways to display multiple variable values on the same line in the Command Window. Concatenate multiple character vectors together using the [] operator. Convert any numeric values to characters using the num2str function. Use disp to display the result.
Select MATLAB > Command Window, and then choose a Numeric format option. See the format reference page for a list and description of all supported numeric formats.
You can get the output you want if you change the format to shortG
(based on Example 5 of the documentation):
>> format shortG
>> 3125.1234.*eye(5) %# Display a sample matrix similar to yours
ans =
3125.1 0 0 0 0
0 3125.1 0 0 0
0 0 3125.1 0 0
0 0 0 3125.1 0
0 0 0 0 3125.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With