How to fit data!
5 views (last 30 days)
Show older comments
I have experimental data and I need to represent it as a function of x using the MATLAB fitting tool.
However, the obtained experimental data were non-linear and were fitted by dividing the intervals.
The problem here is that the fitting is made so that the function values at the points connecting the sections do not match.
Is there a way or code to fix and fit the end value of the interval?
A data example is attached.
It's a long question, but I'll wait for an answer. Thank you.
(If there is an efficient way to represent it as a function, please let me know!)
- There may be some awkward parts using a translator! :)

4 Comments
Image Analyst
on 26 Jan 2022
You said "A data example is attached." but there is no attachment. Use the paperclip icon to attach your file, and give us the code to read it in and plot it.
Accepted Answer
Star Strider
on 25 Jan 2022
This is something similar to Curve Fitting of large Data Measurement? however with a different sort of envelope. I would begin by using the envelope function to get the general shape of the envelope, derive a function that describes it mathematically in terms of the other data (time, amplitude, frequency, perhaps others), then change the code in the Answer I linked to in order to fit the entire function to the data (unless the desired result is only to determine a function for the envelope, if so stop after the envelope determination step).
2 Comments
Star Strider
on 27 Jan 2022
It ocurred to me that this could be a straighttforward system identification problem, and would automatically code for the envelope function as well, since that may not be possible to correctly estimate otherwise.
For best results, I need to know what the inputs were to the system that produced those outputs. It should be a vector (or matrix) of corresponding sample times. The system identification is not going to work well without knowing the inputs.
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/874645/h2_f_og_.csv', 'VariableNamingRule','preserve')
x = T1.x;
Fx = T1.Fx;
Ts = mean(diff(x)) % Sampling Interval
% Tsd = std(diff(x)) % Check Sampling Time Consistency
Fx_data = iddata(Fx,[],Ts)
Fxss_sys = ssest(Fx_data, 8)
figure
compare(Fx_data, Fxss_sys)
.
More Answers (0)
See Also
Categories
Find more on Least Squares in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!