I can't go into too much detail on the application of my code because it is for a confidential project. What I am working on though interfaces with Prolith, a microlithography simulation tool. So posting the entirety of my code here would be useless. My process is as follows:
- Run a bunch of simulations in Prolith from MATLAB
- Get data from Prolith from simulations
- Analyze data to determine response
- Use polyfit function to model response quadratically
My function returns four values:
- dCDA: One of the responses
- sCDA: The second response
- dCDA_model: the modeled dCDA
- sCDA_model: the modeled sCDA
Now here is my problem, when I run my function it returns the incorrect values. However, running the same code from the command window returns the correct values. My x values are in a vector called ZMag.
EDIT: See comment below for corrected data
ZMag =
0 1.93 3.86 5.79 7.72 9.65
dCDA =
-0.0811 0.1554 0.4109 0.7142 1.0336 1.3741
0.0635 0.4425 0.8215 1.2006 1.5791 1.9525
-0.0099 -0.0079 -0.0078 -0.0090 -0.0117 -0.0159
0.0526 -0.1442 -0.3442 -0.5637 -0.7802 -0.9938
sCDA =
-0.1050 -0.5570 -1.0011 -1.4324 -1.8442 -2.2308
-0.1034 0.2494 0.6041 0.9594 1.3145 1.6516
-0.0187 0.1713 0.3622 0.5530 0.7437 0.9392
-0.0908 -0.2982 -0.4927 -0.6840 -0.8622 -1.0330
dCDA_model (incorrect)
151.5506 -15.3017 -19.9054 5.5466
21.1869 38.5986 0.9280 -21.4042
-0.0715 0.0594 -0.0144 0.0662
sCDA_model (incorrect)
155.0786 -33.6812 -19.3941 4.9035
-50.9605 36.9912 20.3325 -18.6355
-0.0700 -0.1135 -0.0295 -0.1105
dCDA_model (correct)
0.0041 -0.0004 -0.0005 0.0001
0.1098 0.2000 0.0048 -0.1109
-0.0715 0.0594 -0.0144 0.0662
sCDA_model (correct)
0.0042 -0.0009 -0.0005 0.0001
-0.2640 0.1917 0.1053 -0.0966
-0.0700 -0.1135 -0.0295 -0.1105
And finally, the code that generated these anomalies:
for i = 1:n
dCDA_model(:,i) = polyfit(ZMag,dCDA(i,:),2);
sCDA_model(:,i) = polyfit(ZMag,sCDA(i,:),2);
end
Any ideas as to what could be causing this disparity in results between the command window and M-File? I am using MATLAB R2007a.
Thank you.