exa14.m
来自「市面上电力系统的范例 直得收藏学习的ㄧ本书」· M 代码 · 共 10 行
M
10 行
x = [ 0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0];
y = [10 10 16 24 30 38 52 68 82 96 123];
p = polyfit(x, y, 2) % finds the coefficients of a polynomial
% of degree 2 that fits the data
yc = polyval(p, x); % polynomial is evaluated at all points in x
plot(x, y,'x', x, yc) % plots data marked by x and fitted polynomial
xlabel('x'), ylabel('y'), grid
title('Polynomial curve fitting')
legend('Actual data', 'Fitted polynomial')
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?