Hello, my code is:
t=1;
h=6.626*10^-34;
e=2.718281828459;
l=1.757*10^-29;
m=1.652*10^-29;
n=0.8*m;
o=2*pi*395581*10^9;
p=2*pi*443941*10^9;
q=2*pi*48360*10^9;
w=1;
M=[0,(0.E-323+sqrt(-1)*0.132584E5),(0.E-323+sqrt(-1)*0.E-323),( ...
0.E-323+sqrt(-1)*(-0.132584E5)),0,0,(0.E-323+sqrt(-1)*0.E-323),0, ...
0;(0.E-323+sqrt(-1)*0.132584E5),(sqrt(-1)*(-1)).*((-1).*o+w),( ...
0.E-323+sqrt(-1)*0.E-323),0,(0.E-323+sqrt(-1)*(-0.132584E5)),0,0,( ...
0.E-323+sqrt(-1)*0.E-323),0;(0.E-323+sqrt(-1)*0.E-323),(0.E-323+ ...
sqrt(-1)*0.E-323),(sqrt(-1)*(-1)).*((-1).*p+w),0,0,(0.E-323+sqrt( ...
-1)*(-0.132584E5)).*e.^(sqrt(-1).*t.*((-1).*o+p+(-1).*q+w)),0,0,( ...
0.E-323+sqrt(-1)*0.E-323);(0.E-323+sqrt(-1)*(-0.132584E5)),0,0,( ...
sqrt(-1)*(-1)).*(o+(-1).*w),(0.E-323+sqrt(-1)*0.132584E5),( ...
0.E-323+sqrt(-1)*0.E-323),(0.E-323+sqrt(-1)*0.E-323),0,0;0,( ...
0.E-323+sqrt(-1)*(-0.132584E5)),0,(0.E-323+sqrt(-1)*0.132584E5),0, ...
(0.E-323+sqrt(-1)*0.E-323),0,(0.E-323+sqrt(-1)*0.E-323),0;0,0,( ...
0.E-323+sqrt(-1)*(-0.132584E5)).*e.^(sqrt(-1).*t.*(o+(-1).*p+q+( ...
-1).*w)),(0.E-323+sqrt(-1)*0.E-323),(0.E-323+sqrt(-1)*0.E-323),( ...
sqrt(-1)*(-1)).*((-1).*q+w),0,0,(0.E-323+sqrt(-1)*0.E-323);( ...
0.E-323+sqrt(-1)*0.E-323),0,0,(0.E-323+sqrt(-1)*0.E-323),0,0,( ...
sqrt(-1)*(-1)).*(p+(-1).*w),(0.E-323+sqrt(-1)*0.132584E5).*e.^( ...
sqrt(-1).*t.*(o+(-1).*p+q+(-1).*w)),(0.E-323+sqrt(-1)*0.E-323);0,( ...
0.E-323+sqrt(-1)*0.E-323),0,0,(0.E-323+sqrt(-1)*0.E-323),0,( ...
0.E-323+sqrt(-1)*0.132584E5).*e.^(sqrt(-1).*t.*((-1).*o+p+(-1).*q+ ...
w)),(sqrt(-1)*(-1)).*(q+(-1).*w),(0.E-323+sqrt(-1)*0.E-323);0,0,( ...
0.E-323+sqrt(-1)*0.E-323),0,0,(0.E-323+sqrt(-1)*0.E-323),(0.E-323+ ...
sqrt(-1)*0.E-323),(0.E-323+sqrt(-1)*0.E-323),0]
but my output is:
M =
1.0e+15 *
Columns 1 through 5
0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 - 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 2.4855i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 - 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 2.7894i 0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 - 2.4855i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i -0.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
Columns 6 through 9
0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.3039i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 - 2.7894i 0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i -0.0000 + 0.0000i 0.0000 - 0.3039i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
For example the second entry. It is not equal to 0. But in the output it is.How can I stop that ?

4 件のコメント

KSSV
KSSV 2022 年 3 月 10 日
They are not zeros....See that a number 1.0e+15 is multiplied to every element.
Stephen23
Stephen23 2022 年 3 月 10 日
"For example the second entry. It is not equal to 0. But in the output it is."
No, it is not equal to zero. Lets have a look at it:
t=1;
h=6.626*10^-34;
e=2.718281828459;
l=1.757*10^-29;
m=1.652*10^-29;
n=0.8*m;
o=2*pi*395581*10^9;
p=2*pi*443941*10^9;
q=2*pi*48360*10^9;
w=1;
M=[0,(0.E-323+sqrt(-1)*0.132584E5),(0.E-323+sqrt(-1)*0.E-323),( ...
0.E-323+sqrt(-1)*(-0.132584E5)),0,0,(0.E-323+sqrt(-1)*0.E-323),0, ...
0;(0.E-323+sqrt(-1)*0.132584E5),(sqrt(-1)*(-1)).*((-1).*o+w),( ...
0.E-323+sqrt(-1)*0.E-323),0,(0.E-323+sqrt(-1)*(-0.132584E5)),0,0,( ...
0.E-323+sqrt(-1)*0.E-323),0;(0.E-323+sqrt(-1)*0.E-323),(0.E-323+ ...
sqrt(-1)*0.E-323),(sqrt(-1)*(-1)).*((-1).*p+w),0,0,(0.E-323+sqrt( ...
-1)*(-0.132584E5)).*e.^(sqrt(-1).*t.*((-1).*o+p+(-1).*q+w)),0,0,( ...
0.E-323+sqrt(-1)*0.E-323);(0.E-323+sqrt(-1)*(-0.132584E5)),0,0,( ...
sqrt(-1)*(-1)).*(o+(-1).*w),(0.E-323+sqrt(-1)*0.132584E5),( ...
0.E-323+sqrt(-1)*0.E-323),(0.E-323+sqrt(-1)*0.E-323),0,0;0,( ...
0.E-323+sqrt(-1)*(-0.132584E5)),0,(0.E-323+sqrt(-1)*0.132584E5),0, ...
(0.E-323+sqrt(-1)*0.E-323),0,(0.E-323+sqrt(-1)*0.E-323),0;0,0,( ...
0.E-323+sqrt(-1)*(-0.132584E5)).*e.^(sqrt(-1).*t.*(o+(-1).*p+q+( ...
-1).*w)),(0.E-323+sqrt(-1)*0.E-323),(0.E-323+sqrt(-1)*0.E-323),( ...
sqrt(-1)*(-1)).*((-1).*q+w),0,0,(0.E-323+sqrt(-1)*0.E-323);( ...
0.E-323+sqrt(-1)*0.E-323),0,0,(0.E-323+sqrt(-1)*0.E-323),0,0,( ...
sqrt(-1)*(-1)).*(p+(-1).*w),(0.E-323+sqrt(-1)*0.132584E5).*e.^( ...
sqrt(-1).*t.*(o+(-1).*p+q+(-1).*w)),(0.E-323+sqrt(-1)*0.E-323);0,( ...
0.E-323+sqrt(-1)*0.E-323),0,0,(0.E-323+sqrt(-1)*0.E-323),0,( ...
0.E-323+sqrt(-1)*0.132584E5).*e.^(sqrt(-1).*t.*((-1).*o+p+(-1).*q+ ...
w)),(sqrt(-1)*(-1)).*(q+(-1).*w),(0.E-323+sqrt(-1)*0.E-323);0,0,( ...
0.E-323+sqrt(-1)*0.E-323),0,0,(0.E-323+sqrt(-1)*0.E-323),(0.E-323+ ...
sqrt(-1)*0.E-323),(0.E-323+sqrt(-1)*0.E-323),0];
It is unclear which element you mean by "second", so lets have at look at both of these:
format long G
M(1,2) % not zero
ans =
0 + 13258.4i
M(2,1) % not zero
ans =
0 + 13258.4i
Most likely you are making the mistake of confusing how data are displayed with what data are stored in memory.
Alland Kiepert
Alland Kiepert 2022 年 3 月 10 日
So on the display there is just a 0 at certain entries because the exact terms would take too much space ?
James Tursa
James Tursa 2022 年 3 月 10 日
Yes

サインインしてコメントする。

 採用された回答

Jan
Jan 2022 年 3 月 10 日
編集済み: Jan 2022 年 3 月 10 日

0 投票

format long g
This enables more visible digits. You get the complete control over the output format, if you use fprintf() instead:
for iR = 1:size(M, 1)
for iC = 1:size(M, 2)
fprintf('%18.16g+%18.16g, ', real(M(iR, iC)), imag(M(iR, iC)));
end
fprintf('\n');
end
% [EDITED, thanks Walter!]

1 件のコメント

Walter Roberson
Walter Roberson 2022 年 3 月 10 日
fprintf('%18.16g+%18.16g, ', real(M(iR, iC)), imag(M(iR, iC) );

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGet Started with MATLAB についてさらに検索

質問済み:

2022 年 3 月 10 日

編集済み:

Jan
2022 年 3 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by