Azzera filtri
Azzera filtri

Applying logic to Curve Fitter Output

46 visualizzazioni (ultimi 30 giorni)
Eric
Eric il 19 Lug 2024 alle 1:57
Spostato: Walter Roberson il 20 Lug 2024 alle 20:35
I am trying to use Curve Fitter and generating the code to help teach myself how to process my data without Curve Fitter.
Is there a way to apply a logic that a certain data point should be lower/higher than another certain data point, and have the coefficients adjust accordingly?
%CREATEFIT(TWOSOUSANDTQSPK,TWOSOUSANDTQAPC,TWOSOUSANDTQNM)
% Create a fit.
%
% Data for '2000 copy 1' fit:
% X Input: twosousandTQSPK
% Y Input: twosousandTQAPC
% Z Output: twosousandTQnm
% Output:
% fitresult : a fit object representing the fit.
% gof : structure with goodness-of fit info.
%
% See also FIT, CFIT, SFIT.
% Auto-generated by MATLAB on 18-Jul-2024 20:43:50
%% Fit: '2000 copy 1'.
[xData, yData, zData] = prepareSurfaceData( twosousandTQSPK, twosousandTQAPC, twosousandTQnm );
% Set up fittype and options.
ft = fittype( 'A+(x*B)+(C*x*x)+(y*x*D)+(y*x*x*E)+(y*F)', 'independent', {'x', 'y'}, 'dependent', 'z' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.MaxFunEvals = 60000;
opts.MaxIter = 40000;
opts.StartPoint = [0.0526769976807926 0.737858095516997 0.269119426398556 0.422835615008808 0.547870901214845 0.942736984276934];
opts.TolFun = 0.1;
opts.TolX = 0.1;
% Fit model to data.
[fitresult, gof] = fit( [xData, yData], zData, ft, opts );
% Plot fit with data.
figure( 'Name', '2000 copy 1' );
h = plot( fitresult, [xData, yData], zData );
legend( h, '2000 copy 1', 'twosousandTQnm vs. twosousandTQSPK, twosousandTQAPC', 'Location', 'NorthEast', 'Interpreter', 'none' );
% Label axes
xlabel( 'twosousandTQSPK', 'Interpreter', 'none' );
ylabel( 'twosousandTQAPC', 'Interpreter', 'none' );
zlabel( 'twosousandTQnm', 'Interpreter', 'none' );
grid off
view( -2.9, 15.3 );
I am looking to apply that the output data should follow the 'twosousandTQSPK' axis relative. I reserached the weighting function, but I I don't know how I could accurately match the data inputs I have to weight it.
This is an example of what I am expecting with a different set of variables, but the results above in question should resemble this outcome to some degree.
%CREATEFIT(SIXTEENTQSPK,SIXTEENTQAPC,SIXTEENTQNM)
% Create a fit.
%
% Data for '1600 copy 2' fit:
% X Input: sixteenTQSPK
% Y Input: sixteenTQAPC
% Z Output: sixteenTQnm
% Output:
% fitresult : a fit object representing the fit.
% gof : structure with goodness-of fit info.
%
% See also FIT, CFIT, SFIT.
% Auto-generated by MATLAB on 18-Jul-2024 20:55:15
%% Fit: '1600 copy 2'.
[xData, yData, zData] = prepareSurfaceData( sixteenTQSPK, sixteenTQAPC, sixteenTQnm );
% Set up fittype and options.
ft = fittype( '(y*A)+B+(x*C)+(D*x*x)+(y*x*E)+(y*x*x*F)', 'independent', {'x', 'y'}, 'dependent', 'z' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.MaxFunEvals = 60000;
opts.MaxIter = 40000;
opts.StartPoint = [0.0430238016578078 0.168990029462704 0.649115474956452 0.73172238565867 0.647745963136307 0.450923706430945];
opts.TolFun = 0.1;
opts.TolX = 0.1;
% Fit model to data.
[fitresult, gof] = fit( [xData, yData], zData, ft, opts );
% Plot fit with data.
figure( 'Name', '1600 copy 2' );
h = plot( fitresult, [xData, yData], zData );
legend( h, '1600 copy 2', 'sixteenTQnm vs. sixteenTQSPK, sixteenTQAPC', 'Location', 'NorthEast', 'Interpreter', 'none' );
% Label axes
xlabel( 'sixteenTQSPK', 'Interpreter', 'none' );
ylabel( 'sixteenTQAPC', 'Interpreter', 'none' );
zlabel( 'sixteenTQnm', 'Interpreter', 'none' );
grid off
view( -0.5, -13.0 );
  3 Commenti
Eric
Eric il 20 Lug 2024 alle 0:59
Thanks again for the quick response. I shouldnt of asked a question quite yet. I just stumbled accross how the starting point in curve fitter can affect the output data quite a bit. I will dabble into this new venture for awhile.
Thank You again!
Eric
Eric il 20 Lug 2024 alle 16:09
Spostato: Walter Roberson il 20 Lug 2024 alle 20:35
Im trying to produce a general trend that point z should be increasing as x and/or y is increasing, with exceptions.
This screenshot is pretty much what I am trying to mimic with my dataset. I can't physically produce the same variety of data points as that example, so I feel that is why I am having difficulty estimating a fit. I have been looking into some sort of a Monte Carlo simulation to help generalize my data, being the TWOSOUSANDTQNM in the raw form is extrememly noisy, and the TWOSOUSANDTQAPC in raw form has known varying +/-5 percent error.
This data was visually cherrypicked moving means to rule out error and noise.
TWOSOUSANDTQAPC
207.500000000000
296.500000000000
367.200000000000
419.300000000000
461.800000000000
506.800000000000
540.600000000000
TWOSOUSANDTQSPK
35.9000000000000
28.5000000000000
22.1000000000000
19.3000000000000
17
14.8000000000000
13.3000000000000
TWOSOUSANDTQNM
95.2000000000000
174.300000000000
227.800000000000
270
301.800000000000
334.600000000000
355.500000000000

Accedi per commentare.

Risposte (0)

Prodotti


Release

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by