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.
"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

fprintf('%18.16g+%18.16g, ', real(M(iR, iC)), imag(M(iR, iC) );

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Get 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