I can't get my error-bar plot to work
이전 댓글 표시
I can't get this code to work:
function [fitresult, gof] = Linearized_plot_uncertainties(inverse_square_radius, time,er)
%%Fit: 'Linearized Fit'.
[xData, yData] = prepareCurveData( inverse_square_radius, time );
% Set up fittype and options.
ft = fittype( 'poly1' );
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft );
% Plot fit with data.
figure( 'Name', 'Linearized Fit' );
h = errorbar(fitresult,'b', xData, yData,'.k',er); %THIS LINE gives me the error message
h(1).MarkerSize = 12;
h(2).LineWidth = 1;
legend( h, 'time vs. inverse_square_radius', 'Linearized Fit', 'Location', 'NorthEast' );
% Label axes
xlabel inverse_square_radius
ylabel time
grid on
hold on;
axis([0 10.5e5 0 40.5]);
I'm getting the following error message:
Error using errorbar (line 66)
Not enough input arguments.
Error in Linearized_plot_uncertainties (line 13)
h = errorbar(fitresult,'b', xData, yData,'.k',er);
When I replace the line with this (removing customization):
h = errorbar(fitresult, xData, yData,er);
I'm getting a different error message:
Error using errorbar (line 76)
Input arguments must be numeric or objects which can be converted to double.
Error in Linearized_plot_uncertainties (line 14)
h = errorbar(fitresult, xData, yData,er);
채택된 답변
추가 답변 (1개)
Steve Slana
2018년 7월 10일
0 개 추천
I think you might need to put your xdata and ydata first as there aren't any indentifiers associated to those parameters?
카테고리
도움말 센터 및 File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!