Function Fplot
Function Fplot
As i have mentioned in previous post function in matlab do have many possible syntaxes. Here i will be using the following syntax for fplot. Syntax: fplot(@(variable) function,[lower_limit upper_limit]); Eg: fplot(@(x) sin(x),[-10 10]); The function fplot is basically used to plot graphs or plots of a function/expression with respect to some variable in that expression.Here we are just interested in plotting a expression with respect to a single variable be it x.So what we need to give to fplot in addition to the function is the variable with respect to which we are plotting,its range.To specify the variable we uses @() and inside brackets we give the variable name.Then next parameter into the fplot is the expression,which follows the previous parameter( @(x))without any comma.Now we need to give the limit of or range of variable.This is given as another parameter within square brackets and lower and upper limits separated with space.And we are done with fplot. Eg: fplot(@(x)sin(x)/x,[-20 20]); This will give you a plot of sinc function. The main advantage of fplot is that however complex be the expression you neednt worry about making changes in that as we did with plot.So this function is simple and flexible.All this advantage is becase unlike plot , fplot takes the range of x axis values within its calling.But for plot we need to use arrays,which makes writing complex expression even more complex.