curve fitting using custom equation error
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
When i am using a custome equation with prediefined variables included, i am getting an error
Error using fittype/testCustomModelEvaluation (line 16)
Custom equations must produce an output vector, matrix, or array that is the same
size and shape as the input data. This custom equation fails to meet that
requirement:
a/(exp((x-M)/(b*St))+1)
Error in fittype>iCreateFittype (line 371)
testCustomModelEvaluation( obj );
Error in fittype (line 328)
obj = iCreateFittype( obj, varargin{:} );
Error in createFit (line 22)
ft = fittype(@(a,b,x) a/(exp((x- M)/(b*St))+1), 'independent', 'x', 'dependent',
'y','coefficients', {'a','b'} );
Here is my code for lotting the curve...
function [fitresult, gof] = createFit(XbyL, S)
[xData, yData] = prepareCurveData( XbyL, S );
M = mean(S)
St = std(S)
% Set up fittype and options.
ft = fittype(@(a,b,x) a/(exp((x- M)/(b*St))+1), 'independent', 'x', 'dependent', 'y','coefficients', {'a','b'} );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.StartPoint = [0.649115474956452 0.73172238565867];
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );
% Plot fit with data.
%figure( 'Name', 'untitled fit 1' );
%h = plot( fitresult, xData, yData );
%legend( h, 'S500 vs. X500', 'untitled fit 1', 'Location', 'NorthEast' );
% Label axes
%xlabel XbyL
%ylabel S
%grid on
0 Kommentare
Antworten (1)
Matt J
am 1 Apr. 2019
ft = fittype(@(a,b,x) a./(exp((x- M)./(b.*St))+1), 'independent', 'x', 'dependent',
'y','coefficients', {'a','b'} );
0 Kommentare
Siehe auch
Kategorien
Mehr zu Linear and Nonlinear Regression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!