 |
cmd_graph |
Function (ROM Call 0x353) |
Executes TI-Basic 'Graph' command.
cmd_graph graphs the requested expressions or functions using the current graph mode.
This function uses the Smart Graph feature (see the TI-Basic manual). It expects the
following layout of the expression stack before calling (ExprEtc should
point to the last item):
Graph mode | Requested layout on the expression stack |
Function graphing | END_TAG var_name expression |
Parametric graphing | END_TAG var_name y_expression x_expression |
Polar graphing | END_TAG var_name expression |
3D graphing | END_TAG y_var_name x_var_name expression |
Graphing sequences and differential equations is not possible using this command. Variable
names are optional, i.e. they may be omitted. In such cases, default variable names are used ("x" for function
graphing, "t" for parametric graphing, "q" for polar graphing, and "x" and "y" for 3D
graphing). For example, to graph the expression sin(t)+sin(2t)
with respect to t (assuming
that the current graph mode is set accordingly), you should do (example "Graph Function"):
// Graph a given function using the current graph settings
#define USE_TI89 // Compile for TI-89
#define USE_TI92PLUS // Compile for TI-92 Plus
#define USE_V200 // Compile for V200
#define MIN_AMS 101 // Compile for AMS 1.01 or higher
#define SAVE_SCREEN // Save/Restore LCD Contents
#include <tigcclib.h> // Include All Header Files
// Main Function
void _main(void)
{
TRY
push_quantum (VAR_T_TAG);
push_parse_text ("sin(t)+sin(2t)");
cmd_graph (top_estack);
ngetchx ();
cmd_disphome ();
ONERR
ENDTRY
}
Or, you can avoid push_parse_text by
transforming the expression into RPN manually (which is very easy):
static ESQ rpn[] = {END_TAG, VAR_T_TAG, VAR_T_TAG, SIN_TAG,
VAR_T_TAG, 2, 1, POSINT_TAG, MUL_TAG, SIN_TAG, ADD_TAG};
cmd_graph (rpn + sizeof(rpn) - 1);
All expressions entered using cmd_graph or cmd_table are
remembered and assigned increasing function
numbers starting with 1. The currently selected 'Y=' functions are deselected. Use
cmd_clrgraph to clear the functions graphed with this
command (they will also be cleared after you go to the Y= Editor application to re-enable
the system 'Y=' functions).
Uses: GraphActivate, GraphOrTableCmd
See also: cmd_table, cmd_drawfunc, cmd_clrgraph