matlab绘制线性回归

Excel has built-in features that you can use to display your calibration data and calculate a line-of-best-fit. This can be helpful when you are writing a chemistry lab report or programming a correction factor into a piece of equipment.

Excel具有内置功能,可用于显示校准数据并计算最佳拟合线。 当您编写化学实验室报告或将校正因子编程到设备中时,这将很有帮助。

In this article, we’ll look at how to use Excel to create a chart, plot a linear calibration curve, display the calibration curve’s formula, and then set up simple formulas with the SLOPE and INTERCEPT functions to use the calibration equation in Excel.

在本文中,我们将研究如何使用Excel创建图表,绘制线性校准曲线,显示校准曲线的公式,然后使用SLOPE和INTERCEPT函数设置简单公式以在Excel中使用校准方程式。

什么是校准曲线,Excel在创建时如何使用? (What is a Calibration Curve and How is Excel Useful When Creating One?)

To perform a calibration, you compare the readings of a device (like the temperature that a thermometer displays) to known values called standards (like the freezing and boiling points of water). This lets you create a series of data pairs that you’ll then use to develop a calibration curve.

要执行校准,您需要将设备的读数(例如温度计显示的温度)与称为标准的已知值(例如水的冰点和沸点)进行比较。 这使您可以创建一系列数据对,然后将其用于绘制校准曲线。

A two-point calibration of a thermometer using the freezing and boiling points of water would have two data pairs: one from when the thermometer is placed in ice water (32°F or 0°C) and one in boiling water (212°F or 100°C). When you plot those two data pairs as points and draw a line between them (the calibration curve), then assuming the response of the thermometer is linear, you could pick any point on the line that corresponds to the value the thermometer displays, and you could find the corresponding “true” temperature.

使用水的冰点和沸点对温度计进行两点校准将具有两个数据对:一个来自将温度计放在冰水(32 ° F或0 ° C)中时的数据对,一个在沸水(212 ° F)中的数据对。或100 ° C)。 当将这两个数据对绘制为点并在它们之间画一条线(校准曲线)时,假设温度计的响应是线性的,则可以在线上选择与温度计显示的值相对应的任何点,然后可以找到相应的“真实”温度。

So, the line is essentially filling in the information between the two known points for you so that you can be reasonably certain when estimating the actual temperature when the thermometer is reading 57.2 degrees, but when you have never measured a “standard” that corresponds to that reading.

因此,该行实际上是在为您填充两个已知点之间的信息,以便您可以合理确定在温度计读数为57.2度时估算实际温度,但是在从未测量与之对应的“标准”时那个读书。

Excel has features that allow you to plot the data pairs graphically in a chart, add a trendline (calibration curve), and display the calibration curve’s equation on the chart.  This is useful for a visual display, but you can also calculate the formula of the line using Excel’s SLOPE and INTERCEPT functions. When you enter these values into simple formulas, you will be able to automatically calculate the “true” value based on any measurement.

Excel具有使您可以在图表中以图形方式绘制数据对,添加趋势线(校准曲线)以及在图表上显示校准曲线方程的功能。 这对于可视显示很有用,但是您也可以使用Excel的SLOPE和INTERCEPT函数来计算线的公式。 将这些值输入简单的公式后,您将能够基于任何测量值自动计算“真实”值。

让我们看一个例子 (Let’s Look at an Example)

For this example, we will develop a calibration curve from a series of ten data pairs, each consisting of an X-value and a Y-value. The X-values will be our “standards,” and they could represent anything from the concentration of a chemical solution we are measuring using a scientific instrument to the input variable of a program that controls a marble launching machine.

对于此示例,我们将从一系列十个数据对中绘制一条校准曲线,每对数据均由一个X值和一个Y值组成。 X值将成为我们的“标准”,它们可以代表从我们使用科学仪器测量的化学溶液浓度到控制大理石发射器程序的输入变量的任何内容。

The Y-values will be the “responses,” and they would represent the reading the instrument provided when measuring each chemical solution or the measured distance of how far away from the launcher the marble landed using each input value.

Y值将是“响应”,它们将代表在测量每种化学溶液时所提供的仪器读数或使用每个输入值所测量的大理石距发射器有多远的距离。

After we graphically depict the calibration curve, we will use the SLOPE and INTERCEPT functions to calculate the calibration line’s formula and determine the concentration of an “unknown” chemical solution based on the instrument’s reading or decide what input we should give the program so that the marble lands a certain distance away from the launcher.

在以图形方式描绘校准曲线之后,我们将使用SLOPE和INTERCEPT函数来计算校准线的公式,并根据仪器的读数确定“未知”化学溶液的浓度,或者确定我们应该给程序提供什么输入,以便大理石从发射器着陆一定距离。

第一步:创建图表 (Step One: Create Your Chart)

Our simple example spreadsheet consists of two columns: X-Value and Y-Value.

我们的简单示例电子表格包含两列:X值和Y值。

Let’s start by selecting the data to plot in the chart.

让我们从选择要在图表中绘制的数据开始。

First, select the ‘X-Value’ column cells.

首先,选择“ X值”列单元格。

Now press the Ctrl key and then click the Y-Value column cells.

现在按Ctrl键,然后单击“ Y值”列单元格。

Go to the “Insert” tab.

转到“插入”标签。

Navigate to the “Charts” menu and select the first option in the “Scatter” drop-down.

导航到“图表”菜单,然后在“散点图”下拉列表中选择第一个选项。

A chart will appear containing the data points from the two columns.

将出现一个图表,其中包含两列中的数据点。

Select the series by clicking on one of the blue points. Once selected, Excel outlines the points will be outlined.

通过单击蓝点之一来选择系列。 选择后,Excel会概述要点。

Right-click one of the points and then select the “Add Trendline” option.

右键单击这些点之一,然后选择“添加趋势线”选项。

A straight line will appear on the chart.

一条直线将出现在图表上。

On the right side of the screen, the “Format Trendline” menu will appear. Check the boxes next to “Display Equation on chart” and “Display R-squared value on chart.” The R-squared value is a statistic that tells you how closely the line fits the data. The best R-squared value is 1.000, which means every data point touches the line. As the differences between the data points and the line grow, the r-squared value drops, with 0.000 being the lowest possible value.

在屏幕的右侧,将显示“格式化趋势线”菜单。 选中“在图表上显示方程式”和“在图表上显示R平方值”旁边的框。 R平方值是一个统计信息,它告诉您线条与数据的拟合程度。 最佳R平方值为1.000,这意味着每个数据点都接触到该线。 随着数据点和线之间的差异增加,r平方值下降,其中0.000为最低可能值。

The equation and R-squared statistic of the trendline will appear on the chart. Note that the correlation of the data is very good in our example, with an R-squared value of 0.988.

趋势线的方程式和R平方统计量将显示在图表上。 请注意,在我们的示例中,数据的相关性非常好,R平方值为0.988。

The equation is in the form “Y = Mx + B,” where M is the slope and B is the y-axis intercept of the straight line.

该公式的形式为“ Y = Mx + B”,其中M是斜率,B是直线的y轴截距。

Now that the calibration is complete, let’s work on customizing the chart by editing the title and adding axis titles.

现在校准已完成,让我们通过编辑标题和添加轴标题来定制图表。

To change the chart title, click on it to select the text.

要更改图表标题,请单击它以选择文本。

Now type in a new title that describes the chart.

现在输入描述图表的新标题。

To add titles to the x-axis and y-axis, first, navigate to Chart Tools > Design.

要将标题添加到x轴和y轴,请首先导航到“图表工具”>“设计”。

Click the “Add a Chart Element” drop-down.

点击“添加图表元素”下拉菜单。

Now, navigate to Axis Titles > Primary Horizontal.

现在,导航至“轴标题”>“主要水平”。

An axis title will appear.

轴标题将会出现。

To rename the axis title, first, select the text, and then type in a new title.

要重命名轴标题,请首先选择文本,然后输入新标题。

Now, head to Axis Titles > Primary Vertical.

现在,转到“轴标题”>“主要垂直”。

An axis title will appear.

轴标题将会出现。

Rename this title by selecting the text and typing in a new title.

通过选择文本并输入新标题来重命名该标题。

Your chart is now complete.

您的图表现已完成。

第二步:计算线方程和R平方统计量 (Step Two: Calculate the Line Equation and R-Squared Statistic)

Now let’s calculate the line equation and R-squared statistic using Excel’s built-in SLOPE, INTERCEPT, and CORREL functions.

现在,让我们使用Excel的内置SLOPE,INTERCEPT和CORREL函数来计算线方程和R平方统计量。

To our sheet (in row 14) we’ve added titles for those three functions. We’ll perform the actual calculations in the cells beneath those titles.

在工作表(第14行)中,我们添加了这三个函数的标题。 我们将在这些标题下的单元格中执行实际计算。

First, we will calculate the SLOPE. Select cell A15.

首先,我们将计算斜率。 选择单元格A15。

Navigate to Formulas > More Functions > Statistical > SLOPE.

导航到“公式”>“更多函数”>“统计”>“斜率”。

The Function Arguments window pops up. In the “Known_ys” field, select or type in the Y-Value column cells.

弹出功能参数窗口。 在“ Known_ys”字段中,选择或键入Y值列单元格。

In the “Known_xs” field, select or type in the X-Value column cells. The order of the ‘Known_ys’ and ‘Known_xs’ fields matters in the SLOPE function.

在“ Known_xs”字段中,选择或键入X值列单元格。 在SLOPE函数中,“ Known_ys”和“ Known_xs”字段的顺序很重要。

Click “OK.” The final formula in the formula bar should look like this:

点击“确定”。 公式栏中的最终公式应如下所示:

=SLOPE(C3:C12,B3:B12)

=SLOPE(C3:C12,B3:B12)

Note that the value returned by the SLOPE function in cell A15 matches the value displayed on the chart.

请注意,SLOPE函数在单元格A15中返回的值与图表上显示的值匹配。

Next, select cell B15 and then navigate to Formulas > More Functions > Statistical > INTERCEPT.

接下来,选择单元格B15,然后导航到“公式”>“更多函数”>“统计”>“截取”。

The Function Arguments window pops up. Select or type in the Y-Value column cells for the “Known_ys” field.

弹出功能参数窗口。 选择或键入“ Known_ys”字段的Y值列单元格。

Select or type in the X-Value column cells for the “Known_xs” field. The order of the ‘Known_ys’ and ‘Known_xs’ fields also matters in the INTERCEPT function.

在“ Known_xs”字段中选择或键入X值列单元格。 “ Known_ys”和“ Known_xs”字段的顺序在INTERCEPT函数中也很重要。

Click “OK.” The final formula in the formula bar should look like this:

点击“确定”。 公式栏中的最终公式应如下所示:

=INTERCEPT(C3:C12,B3:B12)

=INTERCEPT(C3:C12,B3:B12)

Note that the value returned by the INTERCEPT function matches the y-intercept displayed in the chart.

请注意,INTERCEPT函数返回的值与图表中显示的y截距匹配。

Next, select cell C15 and navigate to Formulas > More Functions > Statistical > CORREL.

接下来,选择单元格C15并导航到“公式”>“更多函数”>“统计”>“ CORREL”。

The Function Arguments window pops up. Select or type in either of the two cell ranges for the “Array1” field.  Unlike SLOPE and INTERCEPT, the order does not affect the result of the CORREL function.

弹出功能参数窗口。 选择或键入“ Array1”字段的两个单元格区域之一。 与SLOPE和INTERCEPT不同,顺序不影响CORREL函数的结果。

Select or type in the other of the two cell ranges for the “Array2” field.

选择或键入“ Array2”字段的两个单元格范围中的另一个。

Click “OK.”  The formula should look like this in the formula bar:

点击“确定”。 公式在公式栏中应如下所示:

=CORREL(B3:B12,C3:C12)

=CORREL(B3:B12,C3:C12)

Note that the value returned by the CORREL function does not match the “r-squared” value on the chart. The CORREL function returns “R,” so we must square it to calculate “R-squared.”

请注意,CORREL函数返回的值与图表上的“ r平方”值不匹配。 CORREL函数返回“ R”,因此我们必须对它求平方以计算“ R平方”。

Click inside the Function Bar and add “^2” to the end of the formula to square the value returned by the CORREL function. The completed formula should now look like this:

在功能栏内单击,然后在公式的末尾添加“ ^ 2”,以平方CORREL函数返回的值。 现在,完成的公式应如下所示:

=CORREL(B3:B12,C3:C12)^2

=CORREL(B3:B12,C3:C12)^2

Press Enter.

按Enter键。

After changing the formula, the “R-squared” value now matches the one displayed in the chart.

更改公式后,“ R平方”值现在与图表中显示的值匹配。

第三步:设置公式以快速计算值 (Step Three: Set Up Formulas For Quickly Calculating Values)

Now we can use these values in simple formulas to determine the concentration of that “unknown” solution or what input we should enter into the code so that the marble flies a certain distance.

现在,我们可以在简单的公式中使用这些值来确定该“未知”溶液的浓度或应该在代码中输入的内容,以便使大理石飞行一定距离。

These steps will set up the formulas required for you to be able to enter an X-value or a Y-value and get the corresponding value based on the calibration curve.

这些步骤将设置您所需的公式,以便您能够输入X值或Y值并根据校准曲线获得相应的值。

The equation of the line-of-best-fit is in the form “Y-value = SLOPE * X-value + INTERCEPT,” so solving for the “Y-value” is done by multiplying the X-value and SLOPE and then adding the INTERCEPT.

最佳拟合线的方程式为“ Y值=斜率* X值+截距”,因此,将X值与SLOPE相乘,然后求解,即可得出“ Y值”添加INTERCEPT。

As an example, we put zero in as the X-value. The Y-value returned should be equal to the INTERCEPT of the line of best fit. It matches, so we know the formula is working correctly.

例如,我们将零作为X值。 返回的Y值应等于最佳拟合线的INTERCEPT。 它匹配,所以我们知道该公式正常工作。

Solving for the X-value based on a Y-value is done by subtracting the INTERCEPT from the Y-value and dividing the result by the SLOPE:

通过从Y值减去INTERCEPT并将结果除以SLOPE来完成基于Y值的X值求解:

X-value=(Y-value-INTERCEPT)/SLOPE

As an example, we used the INTERCEPT as a Y-value. The X-value returned should be equal to zero, but the value returned is 3.14934E-06. The value returned is not zero because we inadvertently truncated the INTERCEPT result when typing the value. The formula is working correctly, though, because the result of the formula is 0.00000314934, which is essentially zero.

例如,我们使用INTERCEPT作为Y值。 返回的X值应等于零,但返回的值为3.14934E-06。 返回的值不为零,因为我们在键入值时无意间将INTERCEPT结果截断了。 但是,该公式正常工作,因为该公式的结果为0.00000314934,该值基本上为零。

You can enter in any X-value you’d like into the first thick-bordered cell and Excel will calculate the corresponding Y-value automatically.

您可以在第一个粗边框单元格中输入所需的任何X值,然后Excel将自动计算相应的Y值。

Entering any Y-value into the second thick-bordered cell will give the corresponding X-value. This formula is what you would use to calculate the concentration of that solution or what input is needed to launch the marble a certain distance.

在第二个粗边框单元格中输入任何Y值将得到相应的X值。 该公式是您用来计算溶液浓度或将大理石发射一定距离所需的输入量的公式。

In this case, the instrument reads “5” so the calibration would suggest a concentration of 4.94 or we want the marble to travel five units of distance so the calibration suggests we enter 4.94 as the input variable for the program controlling the marble launcher. We can be reasonably confident in these results because of the high R-squared value in this example.

在这种情况下,仪器读数为“ 5”,因此校准建议浓度为4.94,或者我们希望大理石移动5个单位距离,因此校准建议输入4.94作为控制大理石发射器的程序的输入变量。 由于本示例中的R平方值较高,因此我们可以对这些结果充满信心。

翻译自: https://www.howtogeek.com/399883/how-to-do-a-linear-calibration-curve-in-excel/

matlab绘制线性回归

matlab绘制线性回归_如何在Excel中绘制线性校准曲线相关推荐

  1. 如何用python绘制圆_如何在python中绘制300万个圆圈

    我在熊猫数据框中有许多(〜3M)圆的数据集(每个圆都有x,y和od属性).我想将它们相互绘制以可视化图案 我以前使用较小的数据集(大约15,000个圆圈)完成了此操作,但现在似乎很king琐(到我只有 ...

  2. matlab 三维y轴平面图,#如何在excel中绘制三维坐标系?#excel怎么画图平面坐标图...

    用excel绘制曲线图时如何进行坐标轴转换 点"插入"->"图表"->"XY图","子图表类型"选择&quo ...

  3. matlab怎么画三维坐标的二维图,excel怎么画二维坐标表格图(如何在excel中绘制三维坐标系?)...

    在excle中怎么把二维图形变成三维图形 你说的是图表吗,如果是的话就这样操作 excel2007以上版本:选中图表-点击设计选项卡-最左面有更改图表类型-选择合适的类型-确定 excel2003也是 ...

  4. 在excel日期比对大小_如何在Excel中防止分组日期

    在excel日期比对大小 As a teenager, group dates can be fun. If you have strict parents, that might be the on ...

  5. excel中去重计数_如何在Excel中计数

    excel中去重计数 There are lots of different ways to count things in Excel – maybe you need to count the n ...

  6. 合并的表格怎么加横线_如何在excel中文字后面加横线

    如何在excel中文字后面加横线以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 如何在excel中文字后面加横线 好办啊 ...

  7. excel 重复方差分析_如何在Excel中运行方差方差分析的两种方法

    excel 重复方差分析 Recently, we looked at how to Perform a One-Way Analysis of Variance in Excel. In today ...

  8. 符号在excel中的引用_如何在Excel中添加项目符号

    &符号在excel中的引用 There's no built-in feature for bullets in Excel, like there is in a Word document ...

  9. webbrowser控件 有数据 但页面空白_如何在Excel中实现可以切换不同数据系列的滚珠图?...

    ▲更多精彩内容,请点击上方Excel小铲子▲ 操作系统版本 Windows 10 64位 Excel版本 Microsoft Excel 2016 64位 案例文档下载 链接:https://pan. ...

最新文章

  1. jquery zoom jquery放大镜特效
  2. Android之NDK开发
  3. oracle脂肪分析仪,CEM推出油脂快速分析新技术
  4. 交换机应用之端口模式(access、trunk和hybird)、是否标记(tag、untag)、端口缺省vlan(pvid、native id)...
  5. replace为undefined_手写 XML 转化为 JS对象 方法
  6. 新版开发工具?全新智能设备?华为开发者大会2021(Together)来了!
  7. Swing 100行画图示例
  8. 计算二叉树的叶子结点个数_C++数据结构二叉树统计总结点个数,叶子结点个数,单分支结点个数,双分支结点个数。...
  9. openwrt下使用wget出现Failed to allocate uclient context
  10. 最新 2022维达纸业AI面试真题题库
  11. DCDC和LDO的区别
  12. 通过 jstack 与 jmap 分析一次线上故障
  13. java ajax传递到action_day8——ajax传参到action(Struts2)
  14. linux-网卡名字说明_基本网络配置_修改MTU值
  15. 如何利用 C# 爬取「猫眼电影:国内票房榜」及对应影片信息!
  16. yii2项目实战-博客管理平台的搭建
  17. 微信小程序RSA非对称加密。
  18. 石墨笔记,Onenote,Effie哪个更适合记者?
  19. zynq linux tf卡系统升级,zynq之TF卡写入常见问题
  20. linux安装mysql教程

热门文章

  1. 【自监督学习综述】A Survey on Contrastive Self-Supervised Learning
  2. 【python 视频爬虫】python下载头条视频
  3. python设计模式【8】-模型·视图·控制器-复合模式
  4. 信息学与数学、奥数的关系 信奥和数学的联系与不同
  5. ROC-RK3308-CC开发实例总结--MPU6050运动处理传感器模块调试
  6. 15 个开发者必备的Web开发工具!
  7. (附源码)计算机毕业设计SSM冷链物流管理系统
  8. 26、Spatially Attentive Output Layer for Image Classification
  9. presto + kafka + logstash 实时监控分析nginx日志
  10. SqlServer不同数据库名的还原