Error using matlab.gra​phics.axis​.Axes/set

31 次查看(过去 30 天)
Hi, I am fitting experimental data to get a surface plot through curve fitting tool. However, there seems to be an error as shown below. The code generated from curve fitting tool is also provided for your reference. Thank you.
function [fitresult, gof] = createFit(m1, x, y11)
%CREATEFIT(M1,X,Y11)
% Create a fit.
%
% Data for 'untitled fit 1' fit:
% X Input : m1
% Y Input : x
% Z Output: y11
% 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 15-Aug-2016 21:58:49
%%Fit: 'untitled fit 1'.
[xData, yData, zData] = prepareSurfaceData( m1, x, y11 );
% Set up fittype and options.
ft = fittype( 'A1*y^A2*exp(A3*x*0.01)', 'independent', {'x', 'y'}, 'dependent', 'z' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.StartPoint = [0.964888535199277 0.157613081677548 0.970592781760616];
opts.Upper = [Inf Inf 0];
% Fit model to data.
[fitresult, gof] = fit( [xData, yData], zData, ft, opts );
% Plot fit with data.
figure( 'Name', 'untitled fit 1' );
h = plot( fitresult, [xData, yData], zData );
legend( h, 'untitled fit 1', 'y11 vs. m1, x', 'Location', 'NorthEast' );
% Label axes
xlabel m1
ylabel x
zlabel y11
grid on
view( 124.4, 10.3 );
Error using matlab.graphics.axis.Axes/set While setting the 'XLim' property of 'Axes': Value must be a 1x2 vector of numeric type in which the second element is larger than the first and may be Inf
Error in sfit/plot>iParseInputs (line 269) set( hParent, 'XLim', xlim );
Error in sfit/plot (line 44) [XY, Z, in, out, style, level, hParent] = iParseInputs( obj, varargin{:} );

回答(1 个)

Walter Roberson
Walter Roberson 2016-8-15
The third component of your start point is greater than the third component of your upper bound. That might lead to problems with mixing up upper and lower bound perhaps
  2 个评论
Yogesh T L
Yogesh T L 2016-8-16
Thanks for your response Walter. I have tried to play with your answer by removing or changing the start points of third component but still the same error arises. The plot works well in curve fitting toolbox but not in the generated code. I don't understand the reason for this error.
Yogesh T L
Yogesh T L 2016-8-16
编辑:Walter Roberson 2016-8-16
Initially when
X=[83.208;
83.208
83.208;
83.208;
83.208]
resulted in the above error. However, on changing one of the element in the X vector from 83.208 to 83.209, it gives a 3-D graph. I don't know the reason behind it but let me know if you could explain. Thank you.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Fit Postprocessing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by