How to align gaussian fits at their maximum peaks?

7 views (last 30 days)
Hello, currently I have 5 sets of data saved as .csv files. Each set of data has its maximum y value corresponding to the same x value. I have loaded them into Matlab, and plotted them onto a Matlab Figure. My final goal is to have all of the peaks aligned at their maximum values. In other words, I want the maximum y value for each data peak to correspond to an x value of zero (it doesn't actually matter which x-value, this is just an example). I have attached a screenshot of my graph as it is now. Currently, the maximum y values are lined up, however this does not automatically correspond to the Gaussian fits themselves lining up. Any help with this would be greatly appreciated!
Also, if I have a gaussian fit defined as fsig, is there a way to extract its maximum value? Currently I am using the code a = max(fisg). However, I get this error message: Invalid data type. First argument must be numeric or logical. I am assuming that somehow I need to change the fsig fit to an set of integers and then call on the max. Is there a way to do this and to get rid of this error message?

Accepted Answer

Ben Drebing
Ben Drebing on 12 Jan 2018
I think you will want center your data first so that all their maxes line up before fitting curves. This way, the your curves will be centered at 0 because the data sets were centered at zero.
Another thing you can try, which might give you better results, is to turn the 'Normalize' option on when fitting your data. This will automatically center the fit at x=0.

More Answers (0)

Categories

Find more on Curve Fitting Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!