global fit

Hello,

I am fairly new to Igor. I have a set of experimental viscosity data. I also have a code that generates viscosity data. The code obtains the viscosity values from sixteen coefficients. I need to fit the code generated data against the experimental viscosity data so as to obtain optimal values for the sixteen coefficients (3 of the coefficients are constants, others are temperature dependent, represented by polynomials). I wrote a procedure in Igor to obtain the code values (works well). I then use global fit to fit these data. I have a table that contains the experimental viscosity data (wave1)and pressure values (wave0). For the same pressure values, I obtained the code generated viscosity values (visc). When I use Add Data Sets in the Global Analysis window, I am able to select wave 1 and visc as Y waves. For X-waves, I need to choose wave 0. I am able to choose wave 0 only for wave1 and not for visc. When I right click on X-waves and try to choose wave0, I get an error that says "The wave visc in row1 has different number of point from the X-wave wave0". Am I doing something wrong here? Also, the way the procedure works: it takes the values from wave0 and then, uisng a series of variables computes visc values. Some portions of the code are:

Function preos(wave0, wave1) : FitFunc
wave wave0, wave1
wave visct1
---
for (i=0; i<=6; i+=1)
rp=wave0[i]
---
aa = a*rp/(r*t)^2
bb = b*rp/(r*t)
---
visc[i]=(vn0+vnf)*1E-6
endfor
end

vnf is calculated from the sixteen coeffs.

Thank you very much in advance for any help.

Regards,
Ram
Ram-

Every Y value in a data set you are fitting must have an associated X value. Consequently, the X wave you choose to go with a given Y wave must have the same number of points as the Y wave.
Quote:
For the same pressure values, I obtained the code generated viscosity values (visc). When I use Add Data Sets in the Global Analysis window, I am able to select wave 1 and visc as Y waves. For X-waves, I need to choose wave 0. I am able to choose wave 0 only for wave1 and not for visc.

Maybe I have misunderstood, but it sounds like the "code-gerated" values are the Y values for the model- that is, they are not measured data. Why do you want to include this in the fit?

Your fit function does not match any of the formats for an Igor fit function. I think you may have a fundamental misunderstanding of the fitting process.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
It's hard to understand your problem from the description you provide. So let me just summarize how I see your situation:

you have measured viscosity as a function of pressure. This produces two waves, let's call them W_viscExp and W_pressure. You have done this for a range of different temperatures, so you have several sets of {W_viscExp, W_pressure} waves.

You have a model function that describes the viscosity as a function of pressure, but that model function has 16 parameter values. So what you what like to achieve with the curve fitting is to determine those values for the 16 coefficients that allow the model function to best describe the experimental data. Since you have several experimental sets at different temperatures, a global fit makes sense.

A complication is that your 16 coefficients depend on an additional parameter, temperature. Since your fit function needs to know about the temperature you can try to add the temperature to your model function as a 17th coefficient. Then just set that coefficient to a fixed value (the correct temperature) for every dataset in the global fit panel. Otherwise the model function doesn't know what the temperature of that particular dataset is.

For this you can just use a basic fitting function with the following format:
Function F(w, x) : FitFunc
WAVE w // this wave has 16 entries, one for every parameter
Variable x // the x value (pressure) where Igor wants you to calculate
// the value of the function using the values of the coefficients passed in w

<body of function> // calculate the value of your function here
<return statement>
End


There's no need to make this function directly in the procedure window. Just make it using the curve fitting dialog. And the only data waves that you need to add to the global fit panel are the {W_viscExp, W_pressure} waves, nothing else. You don't precompute any model values, Igor will take care of that for you.