graph fitresult breaks weirdly in plot..?
Informazioni
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Mostra commenti meno recenti
hey,
I'm trying to plot this data like this:
x=[0.1, 0.5, 1, 1.5, 2.5, 3, 3.3, 3.5, 3.7, 4, 4.5, 5, 6, 8, 10, 15, 20, 30, 40, 50, 60, 65, 70, 75, 80, 90, 110, 250, 400, 650, 1000]*1e3;
y=[0.0351,0.1730,0.3280,0.4640,0.6552,0.7219,0.7547,0.7747,0.7927,0.8160,0.8488,0.8756,0.9160,0.9584,0.9798,1.0000,0.9997,0.9822,0.9517,0.9145,0.8749,0.8556,0.8355,0.8155,0.7957,0.7538,0.6800,0.3479,0.1913,0.0622,0.0416];
[xData, yData] = prepareCurveData( x, y);
ft = fittype( '((2*pi*x*a)/sqrt(1+(2*pi*x*a)^2))*(1/sqrt(1+(2*pi*x*b)^2))', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.Lower = [-Inf 1e-06];
opts.StartPoint = [0.107005609113855 0.921912151588772];
opts.Upper = [Inf 3e-06];
[fitresult, gof] = fit( xData, yData, ft, opts );
figure( 'Name', 'untitled' );
h = semilogx( xData, yData , '.');
hold on;
plot( fitresult);

somehow, matlab creates this break in the fitresult, and ignores the second dot in the data.
can you help me understand why and how to fix it?
Risposte (1)
KALYAN ACHARJYA
il 4 Giu 2019
Modificato: KALYAN ACHARJYA
il 4 Giu 2019
somehow, matlab creates this break in the fitresult, and ignores the second dot in the data?.
Second dot id the part of fitting curve.
Both are two different plot, fitting curve is with red points as shown in following code
x=[0.1, 0.5, 1, 1.5, 2.5, 3, 3.3, 3.5, 3.7, 4, 4.5, 5, 6, 8, 10, 15, 20, 30, 40, 50, 60, 65, 70, 75, 80, 90, 110, 250, 400, 650, 1000]*1e3;
y=[0.0351,0.1730,0.3280,0.4640,0.6552,0.7219,0.7547,0.7747,0.7927,0.8160,0.8488,0.8756,0.9160,0.9584,0.9798,1.0000,0.9997,0.9822,0.9517,0.9145,0.8749,0.8556,0.8355,0.8155,0.7957,0.7538,0.6800,0.3479,0.1913,0.0622,0.0416];
[xData,yData]=prepareCurveData(x,y);
ft=fittype('((2*pi*x*a)/sqrt(1+(2*pi*x*a)^2))*(1/sqrt(1+(2*pi*x*b)^2))', 'independent', 'x', 'dependent', 'y' );
opts=fitoptions( 'Method','NonlinearLeastSquares' );
opts.Display='Off';
opts.Lower=[-Inf 1e-06];
opts.StartPoint=[0.107005609113855 0.921912151588772];
opts.Upper=[Inf 3e-06];
[fitresult,gof]=fit(xData,yData,ft,opts );
figure('Name','untitled');
h=semilogx(xData,yData,'.');
hold on;
plot(fitresult,'r*');
grid on;

Questa domanda è chiusa.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!