lsline.m

来自「数值计算常用方法代码集合。对正在学习该课程的同学非常有用。」· M 代码 · 共 24 行

M
24
字号
function [A,B]=lsline(X,Y)%Input    - X is the 1xn abscissa vector%            - Y is the 1xn ordinate vector%Output - A is the coeefficient of x in Ax + B%            - B is the constant coefficient in Ax + B%  NUMERICAL METHODS: Matlab Programs% (c) 2004 by John H. Mathews and Kurtis D. Fink%  Complementary Software to accompany the textbook:%  NUMERICAL METHODS: Using Matlab, Fourth Edition%  ISBN: 0-13-065248-2%  Prentice-Hall Pub. Inc.%  One Lake Street%  Upper Saddle River, NJ 07458xmean=mean(X);ymean=mean(Y);sumx2=(X-xmean)*(X-xmean)';sumxy=(Y-ymean)*(X-xmean)';A=sumxy/sumx2;B=ymean-A*xmean;

⌨️ 快捷键说明

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