Manipulating cfit data/curve to shift fit line along xaxis
32 ビュー (過去 30 日間)
Hello, I would like to know if there is a way to plot a cfit variable shifted horizontally with reference to other data.
Below in figure 1, I have illustrated a set of raw data to which I'd like to fit the red portion to
After creating an x and y variable that represent just the red portion of figure 1 as if that data started at x=0, I went to the curve fitting app to select good starting points and tolerances. By selecting "generate code" and running it, I could then access the cfit variable.
Figure 2 shows the full data from figure 1 plotted with cfit where, clearly, because the data that was fit had been edited to start at x=0, the cfit line also begins at x=0. As you can see, my data has three peaks. In this example, they happen to all look similar, but that will not always be the case.
I want to have the entirety of the raw data shown with a fit for each peak traced over the peak the fit was generated from. Effectivley, I just need to plot the cfit variable shifted horizontally. Does anyone have advice on how to accomplish this?
回答 (1 件)
Matt J 2022 年 4 月 29 日
編集済み: Matt J 2022 年 4 月 29 日
Download these files,
and then do like in the following:
x=x(:); y=y(:); %ensure columns
G=groupTrue([diff(x)>0 & diff(y)>=0;0]);
[starts,stops]=groupLims(G,1); %starting and stopping indices of each segment
plot(x,y); hold on