CFTool: how to get output and use those data
18 次查看(过去 30 天)
显示 更早的评论
I have a signal which I want to "flatten":
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165125/image.jpeg)
There are specific points I select (too complicated to explain why, just trust that I have to select these points):
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165126/image.jpeg)
so when they are superimposed you can see how the selected points mirror the original signal:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165128/image.jpeg)
I then use CFTool and "smoothing spline" model to get the smoothed curve through the selected points:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165129/image.jpeg)
My QUESTION is: how can I now get the x,y points from the CFTool so that I can go back to my original data (stored as an array) and subtract the smoothed curve from the original data and thereby "flatten" the signal. In short, I have created a smoothed "baseline" using CFTool which I want to subtract from the original signal.
I can't figure out how to get these x,y, data out from CFTool. The command "Save to Workspace" generates obscure parameters in my workspace. The MatLab CFTool help is too opaque for me. Is there an easy tutorial for this or better still, do you have an easy explanation?
Thanks!
0 个评论
回答(1 个)
dpb
2017-6-13
I'll grant the CF Tool is really opaque in many ways, fer shure...this is perhaps the most of the many dark corners...
When you save the fit to workspace you're given the opportunity to name the fit object and some other data. For a smoothing spline example I just used SS for the object and SSout for the residuals object.
To use it, with the x vector you have, simply
ySS=SS(x); % evaluate the cfit at x
The content of SS is a fit object; the particulars within such an object are dependent on the type of fit. The information within the cfit object can be accessed from
SSstruct=coeffvalues(SS); % a structure holding the fit object info
>> coeffvalues(SS)
ans =
form: 'pp'
breaks: [1x101 double]
coefs: [100x4 double]
pieces: 100
order: 4
dim: 1
>>
for the one I did with some data here.
See the doc section "Fit Postprocessing" under the 'cfit' documentation to get to the more detailed explanations.
Hopefully that'll get you started.. *)
Feel free to ask more detailed and attach the actual data/object if still have trouble.
4 个评论
dpb
2017-6-14
编辑:dpb
2017-6-15
BTW, you recognize you can do the same thing programmatically as
SS=fit(x1,transposedata1,'smoothingspline');
don't you? x1, transposedata1 each need be column vectors. That's the same fit object returned as that the cftool returns as the fit object with default values.
I still don't quite follow what it's doing in the tool when the none option for x data is selected--there's got to be some x data somewhere!
ADDENDUM OK, as I presumed must be, there's a helper function prepareCurveData that takes the input [] for X and returns the indices to Y after removing NaN/Inf. You can see this if you ask for the Generate Code option under File, calling that function is the first thing the generated function does.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Smoothing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!