⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e452.m

📁 matlab算法集 matlab算法集
💻 M
字号:
%----------------------------------------------------------------------
% Example 4.5.2: Straight-Line Fit                               
%----------------------------------------------------------------------

% Initialize
 
   clc
   clear
   n = 5;
   m = 10*n;
   x = [0 : 4]';
   y = [2.10 2.85 3.10 3.20 3.90]';
   X = zeros (m,2);
   Y = zeros (m,2);

% Fit curve and plot

   fprintf ('Example 4.5.2: Straight-Line Fit\n');		
   a = polyfit (x,y,1);
   X(:,1) = linspace (x(1),x(n),m)';
   Y(:,1) = polyval (a,X(:,1));
   for i = 1 : m
      j = min (i,n);
      X(i,2) = x(j);
      Y(i,2) = y(j);
   end
   graphxy (X,Y,'Straight-Line Fit','x','y','s')
%----------------------------------------------------------------------



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -