How to export Fit result (X and Y) to a text file
Jakub
Dear all,
I admit I don't understand how the fitting result is stored. I fit a 1D wave with a function (for a range of X) and get one wave in return. When I display it, it shows correct X and Y dependency (from the original X and Y waves) but when I export it to a tab-delimited text file, only Y is exported. What do I do wrongly?
Kind Regards,
Jakub
You haven't done anything wrong, you need to create the X wave that you're seeking. The fit result wave uses wave scaling, meaning: Igor stores the start and delta information you need to make the X wave in the fitting result wave itself.
November 5, 2020 at 08:58 am - Permalink
sjr51 is correct. Here are Igor commands that will do it:
fit_wavex = x
Replace "fit_wave" with actual fit result wave's name, "fit_" followed by your Y data wave name.
If you haven't done so yet, I highly recommend going through the Guided Tour- it will introduce you to concepts like wave scaling. Select Help->Getting Started.
November 5, 2020 at 11:44 am - Permalink
In reply to sjr51 is correct. Here are… by johnweeks
Thanks. Works as it should.
Ps. Why was it decided not to create a separate fit Wave for the X values?
November 6, 2020 at 06:48 am - Permalink
The reason is that Igor can have the x-scale built into to data waves in contrast to most other programs. The x values are just linear, i.e., a straight line in the majority of cases, so its a bit of a clutter to drag an extra x-dataset around. Not having to deal with two waves for one data set is actually a big convenience. Igor is most usable if you have / convert your original data to the waveform model as well. The fit is usually created as a waveform data, i.e., the x scaling is calculated with an offset and delta unless the original data was logarithmic. You can read more about wave scaling by executing the following in Igor's command line:
DisplayHelpTopic "The Waveform Model of Data"
By the way, you can also save the fit result, or any waveform model data for that matter, as X/Y-data in a tab-delimited text file without doing the extra step of writing out the x wave (as explained by John). Just check the 'Row positions' checkbox in the Delimited Text export dialogue and the x scale will be written as the first column in the file (see attached screenshot).
November 6, 2020 at 07:59 am - Permalink
If you are using the fit results internally to Igor, the single wave is convenient. If you need model values, the fit result wave isn't actually the best way to do it- the best way would be to invoke the appropriate function with an X value and appropriate coefficient wave to compute more exact results tailored specifically to your use.
Most folks that want to export the fit curve do that in order to import it into Excel. We have a long history of rescuing people from Excel :)
Maybe if you let us know more about your need, we could offer suggestion for other ways to accomplish your goals.
November 6, 2020 at 10:20 am - Permalink