简体   繁体   English

将方程式传递给TI -Nspire CX作为参数?

[英]Passing equation to TI -Nspire CX as parameter?

I want to pass an equation as a parameter in a program when called so I can evaluate it. 我想在调用程序时将方程式作为参数传递给程序,以便对其求值。 My goal is to allow the equation from parameter to have a value plugged in to solve, but the value plugged is based on part of program. 我的目标是允许来自参数的方程式具有插入值来求解,但是插入的值基于程序的一部分。 I also want equation to be adjustable, not hard coded by passing as parameter on program call. 我还希望方程式是可调的,而不是通过在程序调用中作为参数传递来进行硬编码。 How can I do this? 我怎样才能做到这一点?

Edit: I have tried passing it as a string in an parameter to be called. 编辑:我尝试将其作为字符串传递给要调用的参数。

Function("equation")

And then using define to make it a sub function in my program, then call it that way with a var passed. 然后使用define将其设为程序中的子函数,然后通过传递的var进行调用。 I can't get that to work however, I get an error: "variable undefined." 但是,我无法正常工作,但出现错误:“变量未定义”。

I think the issue is linking var passed to sub function to var in equation given. 我认为问题在于将传递给子函数的var与给定方程式中的var链接。 I also tried just passing equation, no quotes, but got similar error. 我也尝试仅传递方程式,不加引号,但遇到类似错误。

Here is one way to do it. 这是一种方法。 The calculations were done in a Notes. 计算是在注释中完成的。

在此处输入图片说明

Maybe something like this could work for you (?): 也许这样的事情可能对您有用(?):

Define LibPub foo(x,fun)=
Func
Local f
expr("f(x):="&string(fun))
Return f(x)
EndFunc

Then you can call foo with the function/equation you want, eg foo(5, x-7) 然后,您可以使用所需的函数/等式调用foo,例如foo(5,x-7)

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM