Question: how to calculate percentage difference matlab?
Answer: diff = x2 - x1; % x2 and x1 are your input variables. x1 is reference and x2 the value to compare.
relDiff = diff / x1;
if abs(relDiff) > tolerance % e.g. 0.01 for 1%
disp('good');
else.
disp('bad');
end.