matlab showing 0 for small number values product
Ältere Kommentare anzeigen
I have matrix with elements have small values. I am taking product of some elements of matrix for 100 times. If I take matrix 10*10 then it shows output but when I take matrix 100*100 then it shows 0. I think it shows 0 because product appears very small value. so how to take product so this small value should display.
Antworten (1)
John D'Errico
am 13 Nov. 2016
help format
Specifically, I'd suggest one of these:
format long g
format short g
5 Kommentare
Jay Hanuman
am 13 Nov. 2016
Jay Hanuman
am 13 Nov. 2016
Bearbeitet: Jay Hanuman
am 13 Nov. 2016
John D'Errico
am 13 Nov. 2016
Bearbeitet: John D'Errico
am 13 Nov. 2016
Sigh. If something did not work, then show what you think is wrong, and I can try to help.
A = rand(5);
A =
0.81472 0.09754 0.15761 0.14189 0.65574
0.90579 0.2785 0.97059 0.42176 0.035712
0.12699 0.54688 0.95717 0.91574 0.84913
0.91338 0.95751 0.48538 0.79221 0.93399
0.63236 0.96489 0.80028 0.95949 0.67874
>> A.^500
ans =
3.2002e-45 0 0 0 2.3231e-92
3.2676e-22 2.5776e-278 3.3001e-07 3.4147e-188 0
0 8.8435e-132 3.1178e-10 7.6742e-20 3.0684e-36
2.1123e-20 3.7234e-10 1.0939e-157 2.6268e-51 1.4855e-15
3.0334e-100 1.7321e-08 4.1794e-49 1.049e-09 7.0823e-85
As far as MATLAB is concerned, those numbers ARE zero. They underflowed.
Below realmmin, MATLAB double precision underflows. It is truly zero as far as MATLAB is concerned.
realmin('double')
ans =
2.2251e-308
Although MATLAB also supports denormalized numbers that go down another 16 digits or so.
realmin/1000000000000000
ans =
2.4703e-323
realmin/10000000000000000
ans =
0
If you really need more than that, then you need to use a higher precision. Thus either sym or HPF.
Jay Hanuman
am 13 Nov. 2016
Walter Roberson
am 13 Nov. 2016
A = rand(5); %start with your standard floating point number
Asym = sym(A); %convert them to symbolic
B = Asym .^ 500; %raise them individually to the 500th power
num_digits = 50; %number of digits you want to see the result to
vpa(B, num_digits)
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!