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

14 vues (au cours des 30 derniers jours)
Ankit Chauhan
Ankit Chauhan le 21 Jan 2022
Commenté : Image Analyst le 12 Avr 2022
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 commentaires
Ankit Chauhan
Ankit Chauhan le 12 Avr 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 le 12 Avr 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.

Connectez-vous pour commenter.

Réponses (1)

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

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by