How can i increase significant digits beyond 5 in basic fittings option in Matlab?

14 ビュー (過去 30 日間)
Ankit Chauhan
Ankit Chauhan 2022 年 1 月 21 日
コメント済み: Image Analyst 2022 年 4 月 12 日
I have plotted data as shown in black dotted curve. I tried to find fitting using tools>basic fittings. Select 6th degree polynomial and tich show equations But here I can see only upto 5 significant digits. How can I get equations with more than 5 significant digits using basic fittings option?
  2 件のコメント
Ankit Chauhan
Ankit Chauhan 2022 年 4 月 12 日
I have used polyfit command,
coeff = polyfit(xdata, ydata, n); % n is degree of polynomial that fits well,
filename = ['Exact_coeff'];
xlswrite(filename, coeff); % this give me exact coeffiecient with all decimal places data.
Image Analyst
Image Analyst 2022 年 4 月 12 日
Well of course. The variables are always at full resolution. We thought you were talking about how you wanted more significant digits in how the numbers were displayed on your graph. For that you'd use sprintf() like I showed you in my Answer below.

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

回答 (1 件)

Image Analyst
Image Analyst 2022 年 1 月 21 日
I'm not sure your equation reflects what was plotted. But anyway to get more decimal places in the text you can just use %.8f, (to get 8 decimal places) like
str = sprintf('y = %.8f * x^2 + %.8f * x^5 + ........................etc
text(xt, yt, str);
To get more decimal places along the y axis, use ytickformat():
% Test data:
x = linspace(0, 4, 1000);
y = -2.0365*x .^ 6 + ...
20.52 * x .^ 5 + ...
-74.37 * x .^ 4 + ...
108.18 * x .^ 5 + ...
-36.839 * x .^ 6 + ...
8.7963 * x + ...
-1.8823e6...
;
plot(x, y, 'b-', 'LineWidth', 2, 'MarkerSize', 30)
grid on;
% Show current format
fmt = ytickformat
fmt = '%g'
% Set y tick label format to be
ytickformat('%.8f')

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by