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

19 Ansichten (letzte 30 Tage)
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 Kommentare
Ankit Chauhan
Ankit Chauhan am 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 am 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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 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')

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by