ode45 Not enough input arguments
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Zachary Whitworth
le 4 Avr 2018
Réponse apportée : CARLOS RIASCOS
le 4 Avr 2018
I am trying to model the differential equation of a low pass RC filter, using this equation: dVout/dt = (-1/RC)(Vout+Vin). I'm modeling Vin as a function, defined in the code below. Here is the ode function's code:
function dvdt = qprime(t,v)
global R
global C
R = 1/(500*2*pi*1*10.^(-6));
C = 1*10.^(-6);
function y = vi(z)
z = [0:0.01:2];
y = 5*sin(30*2*pi*z) + 0.1*sin(5400*2*pi*z);
end
dvdt = [(-1/(R*C))*v(1) + (-1/(R*C))*vi];
end
Here is the file I'm using to run it:
clear all
global R
global C
v0 = [0];
tspan = [0:0.01:2];
ode45(qprime69,tspan,v0)
I keep running into the issue of not having enough input arguments. Can someone help me figure out where I'm going wrong?
0 commentaires
Réponse acceptée
CARLOS RIASCOS
le 4 Avr 2018
try this:
function dvdt = gprime(t,v)
global R
global C
V = 5*sin(30*2*pi*t) + 0.1*sin(5400*2*pi*t);
dvdt = (-1/(R*C))*v + (-1/(R*C))*V;
end
Then create another script like that, to resolve ODE.
clear all
clf
global R
global C
R = 1/(500*2*pi*1*10.^(-6));
C = 1*10.^(-6);
v0 = [0];
tspan = [0:0.001:2];
[t,x]=ode45(@gprime,tspan,v0);
plot(t,x)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations 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!