How to make array of the expression having symbolic variable?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to make an array of the expression having symbolic variables in it.
if true
% clc
clear ALL
syms A Epsilon0 k1 k2 e s d R s f T c0 v0 v x y t
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}),8);
qn2=[];
i=1;
while i<3
qn2(i)=subs(qn1, v, 4); i=i+1; end end Like in the above code , my goal is to create a two element array of the expression qn1 which contains symbolic variables. For each iteration of while loop, it creates qn2(i) array having the expression calculated from qn1 but in that symbolic expression, the v is replaced by 4.
I am getting the error given below.
"If the input expression contains a symbolic variable, use the VPA function instead."
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Conversion Between Symbolic and Numeric finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!