# 2D Graph

To draw 2D graphs in MatDeck you first have to define variables with matrix that has exactly two rows. Data in the first row are x axis positions on the graph and in the second row are y axis graph position.

Graphs can only be placed in the canvas.

Define variable a:= and insert a matrix in it.

Choose the Graph tab→Graph icon, select a position on the canvas where you’d like to place a graph and click the left mouse button. A graph object will appear. Press right the mouse button with your cursor on the graph and select Add Variable.

A list of all available variables will appear. Choose variable a (only variable in our document). A graph for inserted matrix of data will appear.

The graph title and the names of axes are editable. Place your cursor above the graph title and it will change to a text edit arrow. Double click on the title to open a text box. Change title as you’d like and press Enter to save changes. Graph axes can be changed in the same way.

There are several functions that make up the matrix with input data for the 2D graph. The functions are: curve2d – for real value functions, complexcurve2dre – for real part of functions with complex values and complexcurve2dimg – for imaginary part of functions with complex values.

To draw a graph of sine function in interval [-5, 5], type b:=curve2d and variable b with function curve2d inside it will be created.

In the first argument position type sin, to create sin() function, insert symbol x as argument of sin function. On the second argument position type x, meaning that the symbol x in a function sin will be replaced with values that you enter in the next three arguments. In the third argument position type -5 (starting value of interval), in the fourth argument position type 5 (ending value of interval) and in the fifth argument position type the number of samples for x (we inserted 100).

Go to the Graph tab→Graph icon, select a position on the canvas where you’d like to place a graph and hit the left mouse button. Your graph object will appear. Press right the mouse button while your cursor is hovering over the graph and select Add Variable. A list of all available variables will appear, so choose variable b.

Number of curves that you can place on graph is not limited. To place another curve just select a variable from Add Variable option.