MATLAB Answers

plot a fitted curve and specified axes

9 views (last 30 days)
Wave
Wave on 14 May 2020
Commented: Geoff Hayes on 15 May 2020
Heyhey,
I have a problem with the follwing lines
fit_func = fittype("poly1");
fitdata = fit(XValues,YValues,fit_func);
h=plot(ax,fitdata);
-> so I got the error
Error using plot
Data must be numeric, datetime, duration or an array convertible to double.
If I use this line instead:
h=plot(fitdata);
Everything is fine
So my question: how am I able to use plot to creates the line in the axes specified by ax?

  0 Comments

Sign in to comment.

Answers (1)

Geoff Hayes
Geoff Hayes on 14 May 2020
Wave - from plot cfit or sfit object, try doing
plot(fitdata, 'Parent', hAxes)
where hAxes is the handle to your axes.

  2 Comments

Wave
Wave on 15 May 2020
This will result to the error:
Error using cfit/plot>parseinput (line 332)
Must specify both XDATA and YDATA.
Error in cfit/plot (line 46)
[S1,xdata,ydata,S2,outliers,S3,ptypes,conflev] = parseinput(alltypes,varargin);
Geoff Hayes
Geoff Hayes on 15 May 2020
What does the documentation for your version of MATLAB say about using plot and fit objects?

Sign in to comment.

Tags

Products


Release

R2019b

Translated by