MATLAB: Evaluating constants

constantsevaluation

Hello everyone,
I have to evaluate a very complicated number, and its important to me, so i can not use calculator to find because the accuracy will decrease, so I wrote the following code:
gm1 = 0.01;
gm2 = 0.01;
gm4 = 0.04;
gm5 = 0.04;
gm7 = 0.04;
gm8 = 0.2;
re1 = 99;
re2 = 99;
re4 = 24.75;
re5 = 24.75;
re7 = 24.75;
re8 = 4.95;
ro1 = 400e3;
ro2 = 400e3;
ro4 = 100e3;
ro5 = 100e3;
ro8 = 20e3;
R1 = 20e3;
R2 = 20e3;
R3 = 3e3;
R4 = 2.3e3;
R5 = 15.7e3;
R6 = 3e3;
P1 = (R1*ro1)/(R1 + ro1);
P2 = (R2*ro2)/(R2 + ro2);
P3 = (R3*ro5)/(R3 + ro5);
P4 = (R6*ro8)/(R6 + ro8);
K1 = 101*(re8 + P4);
K2 = 101*(re7 + R4);
K3 = 101*(re5 + re4);
K4 = 101*(re1 + re2);
ANS2 = (P4/K4)*101*(100^3)*(R5/(R5+K1))*(P3/(P3+K2))*((P2+P1)/(P1+P2+K3));
as you can see, it is very complicated, now you can see that I will get the error " ??? Undefined function or variable" for all these constant.. so what should i do?

Best Answer

The posted code is working without an error. Matlab#s MLint mentions, that ro4 and all gm* variables are not used. But I do get an error message.
What about this:
ANS2 = 8010.837753694346;
Another impression: The accuracy of the output depends on the accuracy of the inputs. Did you analyse the sensitivity of the output to a variation of the inputs already? If accuracy matters, such an analysis is fundamental.
Related Question