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

19 Ansichten (letzte 30 Tage)
David Cole
David Cole am 12 Nov. 2024 um 18:03
Kommentiert: Walter Roberson am 12 Nov. 2024 um 19:10
How do I prevent the 1.0e+02 factor from being displayed. I want the complete number to be included inside the matrix.

Antworten (2)

Voss
Voss am 12 Nov. 2024 um 18:08

See format.


Umar
Umar am 12 Nov. 2024 um 19:06

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.

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Produkte


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by