简体   繁体   English

如何将一个像元设置为ay值,并让一个公式确定二次方程式中的x值?

[英]How to set a cell to be a y value and have a formula determine the x value in a quadratic equation?

I have a trend line equation of y=0.0031x^2 + 0.1336x + 0.0355. 我有y = 0.0031x ^ 2 + 0.1336x + 0.0355的趋势线方程。 I have the y values in a column and I want to determine the x value for each via formula so I dont have to manually do the calculation 120 times. 我在一列中有y值,我想为每个via公式确定x值,因此我不必手动进行120次计算。

You'd have to solve each one as a quadratic equation 您必须将每个方程求解为二次方程式

So for a y-value y you'd have 所以对于y值y

a*x^2 + b*x + c = y

so 所以

a*x^2 + b*x + (c-y) = 0

and you need the roots of 而你需要的根源

a*x^2 + b*x + c' = 0

where 哪里

c' = c-y

So if you put 0.0031 in A2, 0.1336 in B2 and 0.0355 in D2, The y-values starting in E2 say and then put the values of c' starting in C2 using 因此,如果您在A2中放置0.0031,在B2中放置0.1336,在D2中放置0.0355,则以E2开头的y值表示,然后使用C2开头的c'值

=$D$2-E2

you can get one set of x-values by 您可以通过获得一组x值

=(-$B$2+SQRT($B$2*$B$2-4*$A$2*C2))/(2*$A$2)

and the other set of x-values by 而另一组x值则为

=(-$B$2-SQRT($B$2*$B$2-4*$A$2*C2))/(2*$A$2)

Have added two columns to check value of y calculated from x. 添加了两列以检查从x计算得出的y值。

屏幕截图

There is actually a Excel-Built-In mechanism to solve this kind of problem. 实际上,存在一种Excel内置机制来解决此类问题。

Lets say your y -Values are stored in the first column (A1, A2 and so on). 假设您的y值存储在第一列(A1,A2等)中。

Then you will put the equation you are interested in, in C1, which will look like this, if we assume that the x -Value will be stored in D1: 然后,如果我们假设x值将存储在D1中,则将您感兴趣的方程式放在C1中,它看起来像这样:

=0.0031*POWER($D1,2)+0.1336*$D1+0.0355-A1

Drag down till suited. 向下拖动直到合适。

Now put any number in D1, eg 5. 现在在D1中输入任意数字,例如5。

Drag D1 down till suited. 向下拖动D1直到合适。

Go to the Data-Ribbon and go to the What-If-Analysis and choose the Goal-Seek. 转到数据功能区,然后进行假设分析,然后选择目标搜索。

It should look like this: 它看起来应该像这样:

在此处输入图片说明

Please note that my Excel is German. 请注意,我的Excel是德语。

In the first field, you will choose the range in which the quadratic equation is located, in this case C1. 在第一个字段中,您将选择二次方程式所在的范围,在本例中为C1。 In the second field, you will specify which value you would like to achieve. 在第二个字段中,您将指定要实现的值。 In this case 0. And in the third field, you will specify which range can be altered. 在这种情况下为0。在第三个字段中,您将指定可以更改的范围。 In this case D1. 在这种情况下,D1。

After pressing ok, excel will approximate the root of the function up to a accuracy of 10^-4. 按下ok后,excel会将函数的根近似到10 ^ -4的精度。

You would have to do this by hand for all the value, or record a macro, see what excel does and write a short macro to do it for you. 您将必须手动处理所有值,或者记录一个宏,查看excel的作用并编写一个简短的宏来为您完成此操作。

It is also important to note, that this is only possible since Excel-2010. 同样重要的是要注意,这仅在Excel-2010之后才可行。 But since you have the excel 2016-tag you should be fine! 但由于您拥有excel 2016标签,因此应该没问题!

EDIT: 编辑:

You can use this Macro, to do it for you, if you use the setup as described above: 如果您使用上述设置,则可以使用此宏为您完成此操作:

Sub GS()

Dim rng As Range

For Each rng In Range("A1", "A4") '<~~ Change this to the range needed

    Cells(rng.Row, 3).GOALSEEK goal:=0, ChangingCell:=Cells(rng.Row, 4) 'Change 3 to the column your function is in. Change the 4 to the column you x-Value is in.

Next rng

End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果单元格包含(x,y或z),则允许另一个单元格显示其公式值 - If cell contains (x,y or z) allow for another cell to display its formula value 如何使用Excel在预定义公式中设置另一个单元格的x值 - How to set x value from another cell in a predefined formula using excel Excel 模式公式排除方程中单元格上的返回值 - Excel mode formula to exclude the returned value on a cell in the equation 在Excel中,如何在单元格X中更改单元格Y的值,而仅在单元格X中键入 - How to , in excel, change the value of cell Y from cell X, while only typing in cell X 如何从VBA设置公式以分配单元格值? - How to set a formula from VBA to assign cell value? 如果 cell.value A = x,则 cell.value N = 公式 - If cell.value A = x, then cell.value N = formula 如何在公式单元格中隐藏公式的值 - How to hide a value of a formula in a formula cell 如何使用Apache POI在具有公式的单元格上设置数值? - How to set Numeric value on cell that has a formula using Apache POI? 根据x乘y单元格值填充单元格 - Populate cells based on x by y cell value 如何将 Cells().Select 命令中单元格的值设置为包含公式的单元格的值? - How can I set the value of a cell in Cells().Select command to the value of a cell that has a formula in it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM