How to fit data!

2 ビュー (過去 30 日間)
재열 김
재열 김 2022 年 1 月 25 日
コメント済み: Star Strider 2022 年 1 月 27 日
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 件のコメント
Image Analyst
Image Analyst 2022 年 1 月 26 日
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.
재열 김
재열 김 2022 年 1 月 26 日
@Image Analyst Oh, I edited the post and attached the data. Thanks!

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2022 年 1 月 25 日
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 件のコメント
재열 김
재열 김 2022 年 1 月 26 日
Thanks for your reply!
I thought it was right to approach the data fitting like the page you linked to, so I modified the code to run it. But, as shown in the picture, I found that they are not very similar.
Should I use peak envelope (to get a function of x) to fit as closely as possible to the original data?
Star Strider
Star Strider 2022 年 1 月 27 日
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')
T1 = 251×4 table
x Fx Fy Fz ______ ___________ ___________ _________ 0 0.0016495 -0.00014195 0.0053701 1.0935 0.0014762 0.00023496 0.0051739 2.187 0.00032598 -0.00015709 0.0054594 3.2804 0.00029656 0.00070307 0.0056151 4.3739 0.0012309 -8.01e-05 0.006997 5.4674 0.00016371 -9.65e-05 0.0090012 6.5609 -0.00035602 -9.09e-05 0.0082262 7.6544 -0.0001414 1.35e-06 0.0081911 8.7478 0.0012345 0.00030346 0.0098071 9.8413 0.0015556 0.00011919 0.010114 10.935 -0.00026018 0.00052635 0.015164 12.028 0.0015505 0.00011503 0.016601 13.122 0.0011482 -1.83e-05 0.021914 14.215 0.00087075 -6.07e-05 0.022012 15.309 -0.00092485 7.86e-05 0.02872 16.402 -0.0023217 0.0007304 0.031215
x = T1.x;
Fx = T1.Fx;
Ts = mean(diff(x)) % Sampling Interval
Ts = 1.0935
% Tsd = std(diff(x)) % Check Sampling Time Consistency
Fx_data = iddata(Fx,[],Ts)
Fx_data = Time domain data set with 251 samples. Sample time: 1.09348 seconds Outputs Unit (if specified) y1
Fxss_sys = ssest(Fx_data, 8)
Fxss_sys = Continuous-time identified state-space model: dx/dt = A x(t) + K e(t) y(t) = C x(t) + e(t) A = x1 x2 x3 x4 x5 x6 x7 x8 x1 0.009635 0.2412 0.006551 0.01099 -0.03323 -0.1819 -0.2486 -0.04133 x2 -0.232 0.01263 -0.03631 0.02909 -0.1952 -0.04111 -0.0001147 0.04236 x3 -0.008426 0.03976 -0.08719 0.3809 -0.03252 -0.1163 -0.3864 -0.743 x4 -0.01136 -0.0002404 -0.2501 -0.1937 0.3994 -0.6713 -0.6635 -0.07726 x5 -0.03699 0.01098 -0.2085 -0.01034 -0.2836 -0.03551 -1.613 -2.127 x6 -0.02895 0.04372 -0.9473 0.008575 -0.7482 -6.161 -9.695 -7.186 x7 -0.01104 0.1119 -0.7441 -0.04221 0.04838 -2.865 -5.675 -6.342 x8 -0.02755 0.09637 -0.9548 0.04119 0.3045 -3.905 -4.536 -7.763 C = x1 x2 x3 x4 x5 x6 x7 x8 y1 17.69 0.1826 -0.1761 0.2149 0.007997 0.4935 0.3214 -0.0009668 K = y1 x1 0.334 x2 0.5631 x3 -6.595 x4 2.645 x5 1.094 x6 7.102 x7 1.62 x8 -1.852 Parameterization: FREE form (all coefficients in A, B, C free). Disturbance component: estimate Number of free coefficients: 80 Use "idssdata", "getpvec", "getcov" for parameters and their uncertainties. Status: Estimated using SSEST on time domain data "Fx_data". Fit to estimation data: 98.57% (prediction focus) FPE: 0.0002877, MSE: 0.0002532
figure
compare(Fx_data, Fxss_sys)
.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by