Can you create a plot within your function?
52 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
Matt Fig
2012-11-4
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.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!