Can you create a plot within your function?
53 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Matt Fig
le 4 Nov 2012
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!