Azzera filtri
Azzera filtri

Matrix summation rounding error?

1 visualizzazione (ultimi 30 giorni)
Giuseppe Gallo
Giuseppe Gallo il 23 Mag 2019
Dear all,
I'm having trouble with summation of matrices and difference of the two sum. Here some lines of code:
thetaMN_prev = cellfun(@nansum, theta_prev);
cost_prev = sum(thetaMN_prev,'all');
thetaMN_try = cellfun(@nansum, theta_try);
cost_try = sum(thetaMN_try,'all');
cost_prev - cost_try often returns 0, while
sum(thetaMN_try - thetaMN_prev,'all') ~= 0, but this should be the same calculation mathematically speaking.
When this happens, cost_try and cost_prev are of the order of 1e19.
Is this an error due to some rounding process in function sum(A,'all')?

Risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by