It is quite often required to plot a function like ” Gaussian distribution, a*exp(-(x-b)^2/2c) or f=x^2″
MATLAB has the function to plot and manipulate symbolic equations in a easy way.
For example, if I want to plot y=x^2+3.
If you face this error “Single input must be an existing figure handle or a scalar integerfrom 1 to 2147483646″, please check the definition function.
f=x^2+3 and f=’x^2+3′ are different.
Give a try to define your own function and plot it.
There are two common ways to plot more than 2 data on the same window.
The first method uses one line and is of the form plot(x, function, style#1 ,x, function#2, style#2, ). For example,
The second method involves the use of the “hold on” and “hold off” commands. After creating the first graph, use the “hold on” command, forcing subsequent graphing commands to be placed in the same window. Now type in your second plot command. When you are through, type “hold off”. For example
To add labels to your axes, use the following
xlabel(‘this goes across’)
ylabel(‘this goes up)
When you create plot.m file the same name as plot function, MATLAB complains “Attempt to execute SCRIPT plot as a function”.
Solution: change the name of plot.m file to a different name like plot_test.m