Plotting the output of a function

54 vues (au cours des 30 derniers jours)
positron96
positron96 le 27 Fév 2018
Commenté : positron96 le 27 Fév 2018
I would like to plot the output of the integral function that I made (see below). Basically, I created a function that takes in constants and the function to be integrated. Then I want to plot the integral from t = 0 to t = 1.5. My code does not work. Can someone teach me what to do?
function V_out = homew(tau, Vin);
syms t
Vout = 1 / tau * int(Vin, t)
t = 0 : 0.1 : 1.5
plot(t, Vout)
  2 commentaires
Jan
Jan le 27 Fév 2018
"Does not work" is not useful to describe a problem. Please explain, what happens.
Your t is a symbolic variable, but plot expects numerical values.
positron96
positron96 le 27 Fév 2018
It gives me the error "Not enough input arguments."
So for instance, my inputs are tau = 0.3 and Vin = 10. I know that the integral is 100*t/3 BUT I want the function to plot 100*t/3 for t = 0 to t = 1.5. Do you know how to code this?

Connectez-vous pour commenter.

Réponse acceptée

Birdman
Birdman le 27 Fév 2018
Use subs command.
function V_out = homew(tau, Vin)
syms t
Vout = 1 / tau * int(Vin, t);
t = 0 : 0.1 : 1.5
Vout=subs(Vout,t)
plot(t, Vout)
  1 commentaire
positron96
positron96 le 27 Fév 2018
Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Formula Manipulation and Simplification 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!

Translated by