Why do I recieve an error when trying to change the Line Width of a plot line?

22 ビュー (過去 30 日間)
Klaudio Myrtaj
Klaudio Myrtaj 2022 年 7 月 1 日
編集済み: Walter Roberson 2022 年 7 月 2 日
I obtained a curve with the "Curve Fitter" App and in "Export Options" I chose "Generate a code".
When I try to modify the script just for changing the line width, the code doesn't run any more and returns an error.
Please can anyone help me to fix it? How can I change the line width?
Thank you!

採用された回答

Voss
Voss 2022 年 7 月 1 日
The Name,Value pairs supported in plot from the Curve Fitting Toolbox (reference) are different than the Name,Value pairs supported in plot in base MATLAB (reference).
In particular, LineWidth is not supported in Curve Fitting Toolbox plot, so you have to modify the LineWidth of the appropriate line after the plot call:
% random data
xData = (1:10).';
yData = randn(10,1);
% Set up fittype and options.
ft = fittype( 'poly2' );
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft);
% Plot fit with data.
h = plot( fitresult, xData, yData) % two lines
h =
2×1 Line array: Line (data) Line (fitted curve)
% Set LineWidth of the fit line ( h(2) ) to 2.
set(h(2), 'LineWidth', 2)
  2 件のコメント
Klaudio Myrtaj
Klaudio Myrtaj 2022 年 7 月 1 日
Understood, thank you so much!
Voss
Voss 2022 年 7 月 1 日
You're welcome!

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 7 月 1 日
編集済み: Walter Roberson 2022 年 7 月 2 日
plot() of cfit or sfit objects is not the regular data plot() and does not support line width.
You might be able to locate lines after they are drawn and change their properties.
  1 件のコメント
Klaudio Myrtaj
Klaudio Myrtaj 2022 年 7 月 2 日
Thank you, I didn’t know it. It was the first time I wanted to change the line width of of a curve fit.

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

カテゴリ

Help Center および File ExchangeFit Postprocessing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by