Can you create a plot within your function?
33 ビュー (過去 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!