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

15 views (last 30 days)
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 Comments
Ankit Chauhan
Ankit Chauhan on 12 Apr 2022
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 on 12 Apr 2022
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.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 21 Jan 2022
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')

Categories

Find more on Networks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!