Discrepancy in sparse matrix math, when NaN’s present
I expect result1 and result2 below to be identical, but they aren’t. The discrepancy must be a bug, right? I’m working in R2024b, but the Run output below shows the issue exists as well in whatever the Matlab online engine is now running.
n = 5; m = 3;
S = sparse(n, m);
v=nan(n, 1);
D=sparse(diag(v));
result1=full(v.*S) %correct
result2=full(D*S) %incorrectI expect result1 and result2 below to be identical, but they aren’t. The discrepancy must be a bug, right? I’m working in R2024b, but the Run output below shows the issue exists as well in whatever the Matlab online engine is now running.
n = 5; m = 3;
S = sparse(n, m);
v=nan(n, 1);
D=sparse(diag(v));
result1=full(v.*S) %correct
result2=full(D*S) %incorrect I expect result1 and result2 below to be identical, but they aren’t. The discrepancy must be a bug, right? I’m working in R2024b, but the Run output below shows the issue exists as well in whatever the Matlab online engine is now running.
n = 5; m = 3;
S = sparse(n, m);
v=nan(n, 1);
D=sparse(diag(v));
result1=full(v.*S) %correct
result2=full(D*S) %incorrect sparse, nan, bug?, numeric MATLAB Answers — New Questions









