
Let us see an example related to exponential in Matlab, for exponential we use a Matlab syntax as ‘exp’, exp in parenthesis we take that variable names or we directly take the equation for exponential. Let us discuss examples of Exponential in Matlab. Step 3: then we use a plot statement with appropriate syntax to plot the exponential graph to visualize the exponential data. Step 2: then we use exp to get exponential values of the variable. Step 1: we take variables and assign values. The steps for Exponential plotting of the data using exp and plot statement:.
PLOTTING EXPONENTIAL FUNCTIONS IN MATLAB CODE
The remaining part of the code is similar to the above code where we only have some changes. > help plot By typing the above you will get a detailed explanation of the plot function and also why the string is used as the third parameter in the plot function. If you want to know more about the plot function then I suggest that the matlab documentation is the best, and you can get that by typing the following in the Matlab command window.

Line 7: Here we are using the plot function to create a graph for the given x and y values we have generated. y vector is an exponential vector for the corresponding x axis values. Line 6: We are using the exp function in Matlab to generate the y vector. In line 4 we have selected the figure, now we are cleaning the figure window if there is any figure in the window selected using the clf command. Line 5: Clf is used to clear the current figure window. Line 4: I have used the figure function to select the figure 1 window if it is already there and to create a figure window if it is not there. It is just only because of my convenience and you can choose your own range. There is no particular reason why I have chosen the numbers in the given range. You may have a question in your mind why I have chosen only the numbers between 1 and 5 with the interval 0.1? To know more about the colon operator then you can refer the following(You can also use the linspace to generate the same set of numbers): Colon operator is used to generate numbers in the given range with the required interval.

Line 3: Here we are using the colon operator to generate a set of numbers in the given range. Or if you want to get a detailed explanation then the links are as follows: If you want to know what range & interval are, then you can see them here: Volume of a solid sphere and graph for different radius using Matlab. And also the comment on line 2 states that the range is 1 to 5 and the interval is 0.1. Line 1 & 2: These lines are Matlab comments and they state that the upcoming code is going to be the code for the exponential function. I have saved this program as plotting.m on my local computer.
