Ich brauche Punkte zu zeichnen, die die Koordinaten haben:Wie Eingabewerte, zeichnen sie und finden eine beste Anpassung
(0.8,825.5)
(1.1,1096)
(1.3,1293)
(1.5,1404)
dann muss ich eine Best-Fit-Kurve der folgenden Gleichung finden:
y = x*(a1*x + a2)*(1 – a12*25)
Hier werden a1
, a2
und a12
zurückgegeben.
hier ist das, was ich ohne Glück bisher versucht haben:
Fzn = [0.8 1.1 1.3 1.4];
Dy = [825.5 1096 1293 1404];
x = Fzn;
y = Dy;
expr = 'x * (a1 * x + a2) * (1 - a12 * 25)';
ft = fittype(expr, 'independent', 'x', 'dependent','y');
opts = fitoptions('Method', 'NonlinearLeastSquares');
opts.StartPoint = [1 1 1]; %[a1 a2 a12]
[fitresult, gof] = fit(x, y, ft, opts)
% plot
LFit = feval(fitresult, x);
figure(1);
h = plot(x,LFit,'r-', x, y,'g.');
set(h, 'LineWidth',2)
legend({'Fit Line', 'data points'}, 'Location','SouthEast')
grid on
ich diesen Fehler:
Error using fit>iFit (line 127)
X must be a matrix with one or two columns.
Error in fit (line 108)
[fitobj, goodness, output, convmsg] = iFit(xdatain, ydatain,
fittypeobj, ...
Error in HatcherTireTest2 (line 113)
[fitresult, gof] = fit(x, y, ft, opts)
Plot mehrere Punkte verwenden 'halten auf'. Http://Stackoverflow.com/questions/36667545/custom-equation-curve-fitting-in-matlab/36668335#36668335 für die Kurvenanpassung – xvan
aber wie gebe ich diese Werte ein/plotten sie? – Vbasic4now
Haben Sie in MATLAB dazu? Warum machen Sie nicht eine einfache Regression mit Excel? – 16per9