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

조회 수: 20 (최근 30일)
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 CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by