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 commentaires

KSSV
KSSV le 10 Mar 2022
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 le 10 Mar 2022
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 le 10 Mar 2022
Yes

Connectez-vous pour commenter.

 Réponse acceptée

Jan
Jan le 10 Mar 2022
Modifié(e) : Jan le 10 Mar 2022

0 votes

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 commentaire

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by