plot a fitted curve and specified axes

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?

3 件のコメント

Alexander Richter
Alexander Richter 2022 年 1 月 28 日
Iam stucked at the same issue, did not find a solution yet. Any updates on the problem? Thanks
Geoff Hayes
Geoff Hayes 2022 年 1 月 29 日
@Alexander Richter - are you using the same code or something different? Please provide details.
Wave
Wave 2022 年 2 月 10 日
@Alexander Richter No updates from my side. Still using it without the specification of ax

サインインしてコメントする。

回答 (1 件)

Geoff Hayes
Geoff Hayes 2020 年 5 月 14 日

0 投票

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

4 件のコメント

Wave
Wave 2020 年 5 月 15 日
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 2020 年 5 月 15 日
What does the documentation for your version of MATLAB say about using plot and fit objects?
Marleen
Marleen 2022 年 2 月 9 日
Why is it possible to specify the parent axes (a Name Value pair) for sfit objects but not for cfit?
Geoff Hayes
Geoff Hayes 2022 年 2 月 10 日
@Marleen - you may want to ask this as a new question.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeFit Postprocessing についてさらに検索

製品

リリース

R2019b

タグ

質問済み:

2020 年 5 月 14 日

コメント済み:

2022 年 2 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by