Info

This question is closed. Reopen it to edit or answer.

Data type causing mismatch between Excel and Matlab

1 view (last 30 days)
Rama
Rama on 11 Nov 2014
Closed: MATLAB Answer Bot on 20 Aug 2021
I have defined a matlab function (see below) with some inputs and outputs. Outputs are a result of some equations with in the matlab function. There is one such equation that computes values very close to 1.0 and because of the data type issue, i am not able to match the excel results to matlab results. I prototyped the model in Excel already and after satisfactory results, i started building up the model in matlab for a more wider analysis of data. Here is the code:
function [A, B, C, D, E,F,G,H] = Control(Rawdata, a, b, c, Constant1)
D = Rawdata/(constant*a);
if(D>=1)
value=1;
else
value=0;
end
As I mentioned earlier, D ranges between 0.978 to 1.004. My model is based on this D value equal to or greater than 1.0. Matlab's output has more 1s than excel and I guess number precision is the cause. Can someone help me figure this out.
Thanks a lot.
  1 Comment
Geoff Hayes
Geoff Hayes on 12 Nov 2014
Rama - does the Excel implementation have a similar function that computes D as above? If so, what can you say about the Rawdata, constant, and a variables that both MATLAB and EXCEL use? Are they identical, similar or ..? It must be one of these three variables that is causing the difference between the two applications.

Answers (0)

Community Treasure Hunt

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

Start Hunting!