MATLAB: How to graph an equation with one independent variable

graphing

I have the equation:
c=(M/(pi*4*D*t))*exp((-r^2)/(4*D*t));
All of the variables,(M,D and t) are defined above the equation and i want to graph this equation where C is the dependent variable and r is the independent variable. How do I go about doing this? Thanks

Best Answer

Just use ezplot. Assume the other variables are defined in advance. Else how could you plot it if they are not?
M = ???
D = ???
t = ???
Cfun = @( r) (M/(pi*4*D*t))*exp((-r.^2)/(4*D*t));
ezplot(Cfun)
Note the use of r.^2, to allow ezplot to use vectorized calls to this function handle.
If you wish to specify the axis limits, ezplot allows you to do so in the second argument.
Related Question