Preventing factor oursite matrix when using the disp() function.

1 次查看(过去 30 天)
How do I prevent the 1.0e+02 factor from being displayed. I want the complete number to be included inside the matrix.

回答(2 个)

Voss
Voss 2024-11-12

See format.


Umar
Umar 2024-11-12

Hi @David Cole,

I do agree with @Voss comments. In MATLAB, when the numbers in a matrix are very large or very small, the default display format may switch to scientific notation. To ensure that the complete numbers are displayed without this notation, you can change the display format using the format command. Specifically, using format long will allow MATLAB to display more digits and avoid scientific notation for most cases. Here is how you can modify your code to achieve the desired output:

% Define the admittance values
Y11 = 1/(0.21) + 1/(0.009i);
Y12 = 1/(0.0091);
Y13 = 0;
Y21 = 1/(0.0091);
Y22 = 1/(0.0091) + 1/(0.027i);
Y23 = 1/(0.0271);
Y31 = 0;
Y32 = 1/(0.027i);
Y33 = 1/(0.21) + 1/(0.027i);
% Create the Ybus matrix
Ybus = [Y11, Y12, Y13; Y21, Y22, Y23; Y31, Y32, Y33];
% Set the display format to long to avoid scientific notation
format long;
% Display the Ybus matrix
disp(Ybus);

Please see attached.

The admittance values are calculated using complex numbers, where i represents the imaginary unit. The matrix Ybus is constructed using the previously defined admittance values. The command format long is used to change the output format to long, which displays more digits and reduces the likelihood of scientific notation. Finally, the disp function is called to output the Ybus matrix.

Hope this helps.

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

标签

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by