How to plot a function which involves symbolic variable?
Mostrar comentarios más antiguos
Hi, My goal is to plot a function "qn2" which involves symboliv variables against a time vector t2. Following is the code.
clc
clear ALL
syms A Epsilon0 k1 k2 e s d R s f T c0 v0 v
An = 0.5*10^(-9);
Epsilon0n = 8.85*10^-12;
k1n = 10;
k2n = 10;
en = 1.6*10^-19;
sn = 1.8*10^(-9);%m gap size%
dn = 3*sn; % total distance
Rn = 1;
c0n=(An*Epsilon0n*k1n)/dn;
t1=0:0.1:5; fn=1000; v0n=7.5; Tn=5/f; vn=v0n*sin(2*3.14*fn*t1); plot(t1,vn);
inits = 'q(0)=(20*10^(-20)),Q(0)=0';
[q,Q] = dsolve('Dq=((v/R)-(1/R)*(((d*q)+(s*Q))/(c0*d)))','DQ=(((q+Q)/(A*Epsilon0*k1))*s)',inits);
qn1 = vpa(subs(q,{A,Epsilon0,k1,k2,e,s,d,R,c0},{An,Epsilon0n,k1n,k2n,en,sn,dn,Rn,c0n}),3);
i=1;
while i<length(t1);
qn2(i)=subs(qn1, [v,t], [vn(i),t1(i)]); i=i+1; end t2=t1(1:50); plot(t2,qn2)
The error I am getting is ??? Error using ==> plot Conversion to double from sym is not possible.
Error in ==> dsolvenew at 33 plot(t2,qn2)
I would really appreciate prompt help.
Respuestas (0)
Categorías
Más información sobre Line Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!