Azzera filtri
Azzera filtri

How to display the matrix as not 10^3 but as 10^1 for the values in the matrix

4 visualizzazioni (ultimi 30 giorni)
Y11=-((482.34i*10^-6));
Y22=-1.99i;
Y33=-2.14i;
Y44=-4.222i;
Y55=-7.761i;
Y66=(416.67*10^-6)- ((57.81*10^-9)*i);
Y77=(166.6*10^-9)- ((166.6*10^-6)*i);
Y12=0;
Y13=0;
Y14=0;
Y15=0;
Y16=0;
Y17=0;
Y21=0;
Y23=0;
Y24=1.351i;
Y25=0.581i;
Y26=0;
Y27=0i;
Y31=0;
Y32=0;
Y34=0;
Y35=0;
Y36=0;
Y37=0;
Y41=0;
Y42=1.3551i;
Y43=Y34;
Y45=0.871i;
Y46=0;
Y47=0;
Y51=Y15;
Y52=Y25;
Y53=0;
Y54=Y45;
Y56=0;
Y57=0;
Y61=0;
Y62=0;
Y63=0;
Y64=0;
Y65=Y56;
Y67=0;
Y71=0;
Y72=0;
Y73=0;
Y74=0;
Y75=0;
Y76=0;
% Ybus matrix
Ybus0 = [Y11,Y12,Y13,Y14,Y15,Y16,Y17; Y21,Y22,Y23,Y24,Y25,Y26,Y27; Y31,Y32,Y33,Y34,Y35,Y36,Y37; Y41,Y42,Y43,Y44,Y45,Y46,Y47; Y51,Y52,Y53,Y54,Y55,Y56,Y57; Y61,Y62,Y63,Y64,Y65,Y66,Y67; Y71,Y72,Y73,Y74,Y75,Y76,Y77,]
%convert Ybus to Zbus
Zbus0=inv(Ybus0);
How to display the matrix as 10^1?
  1 Commento
Stephen23
Stephen23 il 1 Mag 2024
Modificato: Stephen23 il 1 Mag 2024
"How to display the matrix as not 10^3 but as 10^1 for the values in the matrix"
Not easily, you would probably have to write your own display routine, e.g. using FPRINTF.
Here is a much better way to generate that matrix:
Y = zeros(7,7);
Y(1,1) = -(482.34e-6i);
Y(2,2) = -1.99i;
Y(3,3) = -2.14i;
Y(4,4) = -4.222i;
Y(5,5) = -7.761i;
Y(6,6) = (416.67e-6)-(57.81e-9i);
Y(7,7) = (166.6e-9)-(166.6e-6i);
Y(2,4) = 1.351i;
Y(2,5) = 0.581i;
Y(4,2) = 1.3551i;
Y(4,3) = Y(3,4); % superfluous
Y(4,5) = 0.871i;
Y(5,1) = Y(1,5); % superfluous
Y(5,2) = Y(2,5);
Y(5,4) = Y(4,5);
Y(6,5) = Y(5,6); % superfluous

Accedi per commentare.

Risposte (1)

SAI SRUJAN
SAI SRUJAN il 1 Mag 2024
Hi Gihahn,
I understand that you are facing an issue in displaying the matrix as 10^1 for the values in the matrix.
Please go through the following code sample, to proceed further.
Zbus0 = inv(Ybus0);
% Display Zbus0 with values formatted as 10^1
for row = 1:size(Zbus0, 1)
for col = 1:size(Zbus0, 2)
element = Zbus0(row, col);
elementStr = sprintf('%.2fe+01', real(element) / 10) + " + " + sprintf('%.2fe+01', imag(element) / 10) + "i";
fprintf('Z(%d,%d) = %s\n', row, col, elementStr);
end
fprintf('\n');
end
The code will print each element of the matrix Z in a format emphasizing its scaling by (10^1). The 'sprintf' function is used to format both the real and imaginary parts of each complex number separately, and then they are concatenated with an "i" to represent the imaginary unit. This approach provides clear visibility into the magnitude of each element relative to (10^1).
For a comprehensive understanding of the 'fprintf' and 'sprintf' MATLAB function, please go through the following documentation.
I hope this helps!

Categorie

Scopri di più su Time Series Collections in Help Center e File Exchange

Tag

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by