Why do I recieve an error when trying to change the Line Width of a plot line?
조회 수: 12 (최근 30일)
이전 댓글 표시
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!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1052915/image.png)
댓글 수: 0
채택된 답변
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
% Set LineWidth of the fit line ( h(2) ) to 2.
set(h(2), 'LineWidth', 2)
추가 답변 (1개)
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Fit Postprocessing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!