Why I am getting error message when I try to define line specs of a plot?
12 ビュー (過去 30 日間)
古いコメントを表示
Hello
I am trying to fit a curve to a data and create a plot. The code creates the plot, but when I define the line width, it gives error message;
f = fittype('a + b*log(x)',...
'dependent',{'y'},'independent',{'x'},...
'coefficients',{'a','b'});
fit1 = fit( time1, strain1, f )
plot(fit1,'k-','LineWidth',2)
The error message I got is below;
fit1 =
General model:
fit1(x) = a + b*log(x)
Coefficients (with 95% confidence bounds):
a = 0.04434 (0.04336, 0.04532)
b = 0.004645 (0.004399, 0.004891)
Index exceeds matrix dimensions.
Error in cfit/plot (line 66)
ydata = ydata(idx);
It does not give any error message if I do not define 'LineWidth'.
Waiting for your kind help.
Regards
0 件のコメント
採用された回答
Walter Roberson
2019 年 4 月 8 日
plot() for cfit objects is not the generalized plot function. It does not accept LineWidth parameters.
You should proceed like
h = plot(fit1, 'k-');
set(h, 'LineWidth', 2);
その他の回答 (2 件)
TADA
2019 年 4 月 8 日
You are using an overload of plot that accepts a cfit object
this overload doesn't support all the functionality of the regular plot function
you can calculate the fit data and plot that, or you can take a handle of the curve and fix that later:
time1 = (1:100)';
strain1 = log(time1);
f = fittype('a + b*log(x)',...
'dependent',{'y'},'independent',{'x'},...
'coefficients',{'a','b'});
fit1 = fit( time1, strain1, f );
% calculate the fit vector and plot numbers
y = feval(fit1, time1);
plot(time1, y, 'k-', 'LineWidth', 2);
% manipulate the curve handle after plotting
h = plot(fit1,'k-');
h.LineWidth = 2;
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Interpolation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!