Undefined variable while computing ode45 in matlab and issue with the vector lengths after computing ode.
Afficher commentaires plus anciens
I computed my results using ode45. The main function m file is given below.
function qprime=memcapfinal(t,q);
e = 1.6*10^(-19); %C electron charge%
h = 6.63*10^(-34); %J/s planks constant%
phi = (0.3)*1.6*10^(-19); %J barrier height%
R=1;
Epsilon0 = 8.85*10^-12;
k1 = 100;
k2 = 10;
d=10*10^(-9);
s = 6*10^(-9);
m = 9.11*10^(-31); %kg electron mass%
A = 10^(-4);
b = -4*3.14*s/h;
c0=(A*Epsilon0*k1)/d;
f=10000;
v0=7.5;
T=5/f;
v=v0*sin(2*3.14*f*t);
qprime=[((v(:)/R)-(1/R)*(((d*q(1))+(s*q(2)))/(c0*d)));(sqrt(2*m*phi)/s*(e/h)^2*(((q(1)+q(2))/(2*A*Epsilon0*k2))*s)*exp(b*sqrt(2*m*phi)))*A];
AND calling m file is give as follows.
clear all;
clc;
f1=10000;
v01=7.5;
t1=0:0.0000001:0.0005;
v1=v01*sin(2*3.14*f1*t1);
q0=[10^(-20) 10^(-20)];
tspan1=[0,0.0005];
[t,q]=ode45(@memcapfinal,tspan1,q0);
subplot(2,2,2)
plot(t,q(:,1))
subplot(2,2,3)
plot(t,q(:,2))
subplot(2,2,4)
plot(t,v)
Error: ??? Undefined function or variable 'v'.
Error in ==> ode45call at 21 plot(t,v)
Comment : Although I have defined the v in memcapfinal.m file. Moreover I am getting the length(t) of t as 133 which I don't why is it so? My goal is to plot q(1) vs v and this q(1) is calculated by ode45. for that both must have the same lengths but q(1) length is 1 and v is undefined.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Code Execution dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!