ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   how do i do an inline function like in matlab (https://www.excelbanter.com/excel-worksheet-functions/7745-how-do-i-do-inline-function-like-matlab.html)

jonathon wycherley

how do i do an inline function like in matlab
 
in excel i want to be able to type in a equation ie y=2x then in another cell
refer to and use this as a formula to do a calculation. but when you change
the equation the formula in the claculation changes to the new equation like
in matlab the inline function

Art

You might consider named cells.

Example:

put 2 in A1. Then name A1 as x. (insert, name, define -- or just type x in
the "name box" when cell A1 is selected.
Next put =2*x in cell A2. Name it y.
Now you can write another equation referencing x or y anywhere you like.

Be careful of something. You can't give your cells valid cell references as
names. For example, you can't name a cell A5 or BA12.

Art




Hi

I am not familiar with matlab at all, and I am fairly new
to Excel - but I think to do what you want to do would
require you to inplement some quite funky code. Also I am
assuming that y would be the cell showing the result, and
x is an input variable of some kind. I think you would
end up having to create a function "ParseAndCalc
(InputFormula, variableX, VariableY, Variable.....)

In your function you would then need to parse out the
operators and wite equivalent functions for +-/^ etc and
then figure out which variables to pass to them, figure ot
what is a literal value and pass this around - all a lot
of fun to do! THough givcen my relative newbie-ness there
may be another far simpler way someone else can suggest.

Frank Kabel

Hi
Excel is not designed for such things. This would require some VBA coding,
etc.

--
Regards
Frank Kabel
Frankfurt, Germany

jonathon wycherley wrote:
in excel i want to be able to type in a equation ie y=2x then in
another cell refer to and use this as a formula to do a calculation.
but when you change the equation the formula in the claculation
changes to the new equation like in matlab the inline function




hrlngrv - ExcelForums.com

Frank Kabel wrote...
Excel is not designed for such things. This would require some

VBA
coding, etc.

...

Inline functions would require some rather sophisticated VBA coding to
ensure that parsing worked correctly, and there are very few
respondents in these newsgroups who have any experience writing
lexical analyzers or parsers who could provide support in
development.

Better to be more forthright: Excel can't do this without a lot of
agonizing programming, and even then the results will be less than
satisfactory. If the OP wants math software functionality, the OP
should use math software, not Excel. Perhaps siag (a linux/unix
spreadsheet implemented in Scheme, this the name - Scheme In A Grid)
would provide this, but it's the only one I can think of that might
be able to.
---------
www.coffeecozy.com

Use your Bodum and give up cold coffee for good!


All times are GMT +1. The time now is 04:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com