02-16-2011 12:17 PM
Hi,
I need to know how you can translate a string, a formula, to the block diagram. So for instance, if you have G=5+3*lnW, how can you translate the ln to the ln in the block diagram. The formula isn't fixed so I can't make a hard code.
Thanks in advance
KF_
02-16-2011 12:25 PM - edited 02-16-2011 12:27 PM
edit: oops didn't see that the formula always changes
02-16-2011 12:30 PM
The goal is that I can give in the formula in the front panel, not in the block diagram like the formula node
02-16-2011 12:36 PM
Check this out, my friend:
http://zone.ni.com/reference/en-XX/help/371361G-01/gmath/advanced_formula_vis/
02-16-2011 12:39 PM
That's great - I just learned something new!
02-16-2011 12:39 PM
You would need to write a parser that would evaluate the equation entered. If you use RPN this is fairly easy to do. RPN is nice since it lends itself well to using a stack for processing the equation and you will always be dealing no more than the top two elements of the stack. Your evaluation routine would be in a loop that would parse the equation and invoke the proper case in a simple state machine. You will need to use a shift register to store the variables, operations and intermediate results as you parse the equation. You would need a case for each operation you will support.
02-16-2011 12:46 PM
Ok, these comments should help me enough, cheers
02-16-2011 04:51 PM