MATLAB: Can you create a plot within your function

functiongraphplot

I was wondering if it is possible to create a function which will create plot of some values. Normally, I would write something like:
function[VR,VC]=RC(V,R,C,t)
VR = (V*(exp(-t/(R*C))));
VC = (V*(1-exp(-t/(R*C))));
But would I be able to expand this function to create a graph of VR against VC, so instead of numerical values I would get a graph? Is this actually possible?

Best Answer

Sure it is possible! Functions do not have to return anything:
function[]=RC(V,R,C,t)
VR = (V*(exp(-t/(R*C))));
VC = (V*(1-exp(-t/(R*C))));
plot(VR,VC)
Now from the command line:
RC(5,.01,.02,0:.01:5)
Note that you could have the function return those values, and plot too. Just because a function says in its declaration line that it returns values doesn't mean you have to request them when calling it.