printstaya.blogg.se

Plotting exponential functions in matlab
Plotting exponential functions in matlab








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:.

  • fixed point array power.The syntax for Exponential in Matlab is as shown below:įor Exponential plotting of the data, we use exp and plot statements.
  • I have saved this file as plotting1.m on my local computer. %Tan function %For tan also we will use -pi to pi %cos function %For cos also we will use -pi to pi %Sine function %For sine we will use in range of -pi to pi %Exponential function %All the ranges and interval are same as the program 1. It depends on your convenience,Īnd next the change is only in the third parameter of the plot function which I strongly suggest you to give a glance at the plot function official documentation to get a good idea of the same. The changes are the range used for different functions are different.

    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.

    plotting exponential functions in matlab

    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.

    plotting exponential functions in matlab

    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.








    Plotting exponential functions in matlab